How to use the @glimmer/util.assertNever function in @glimmer/util

To help you get started, we’ve selected a few @glimmer/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder.ts View on Github external
symbols: Symbols
): WireFormat.Statement[] {
  let out: WireFormat.Statement[] = [[Op.OpenElement, name, !hasSplat(attrs)]];
  if (attrs) {
    let { attributes, args } = buildAttrs(attrs, symbols);
    out.push(...attributes);
    assert(args === null, `Can't pass args to a simple element`);
  }
  out.push([Op.FlushElement]);

  if (Array.isArray(block)) {
    block.forEach(s => out.push(...buildStatement(s, symbols)));
  } else if (block === null) {
    // do nothing
  } else {
    throw assertNever(block);
  }

  out.push([Op.CloseElement]);

  return out;
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
// BuilderCallExpression
    }
  } else if (typeof expression !== 'object') {
    switch (typeof expression) {
      case 'string': {
        return normalizeDottedPathExpression(expression);
      }
      case 'boolean':
      case 'number':
        return { type: ExpressionKind.Literal, value: expression };

      default:
        throw assertNever(expression);
    }
  } else {
    throw assertNever(expression);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
);
        }
      }
      // BuilderCallExpression
    }
  } else if (typeof expression !== 'object') {
    switch (typeof expression) {
      case 'string': {
        return normalizeDottedPathExpression(expression);
      }
      case 'boolean':
      case 'number':
        return { type: ExpressionKind.Literal, value: expression };

      default:
        throw assertNever(expression);
    }
  } else {
    throw assertNever(expression);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / concat.ts View on Github external
} else if (Array.isArray(action)) {
    for (let item of action) {
      concatStatements(context, item);
    }
  } else if (action.type === 'Number') {
    pushOp(context.encoder, context.syntax.program.constants, action);
  } else {
    if (action.type === 'Compile') {
      pushCompileOp(context, action);
    } else if (action.type === 'Resolution') {
      pushResolutionOp(context.encoder, context, action, context.syntax.program.constants);
    } else if (action.type === 'Simple') {
      pushBuilderOp(context, action);
    } else if (action.type === 'Error') {
    } else {
      throw assertNever(action, `unexpected action type`);
    }
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
};
        }
      }
      case 'boolean':
      case 'number':
        return {
          expr: { type: ExpressionKind.Literal, value: expression },
          kind: HeadKind.AppendExpr,
          trusted: true,
        };

      default:
        throw assertNever(expression);
    }
  } else {
    throw assertNever(expression);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder-interface.ts View on Github external
if (Array.isArray(statement)) {
    if (statementIsExpression(statement)) {
      return normalizeAppendExpression(statement, ExpressionContext.AppendSingleId);
    } else if (isSugaryArrayStatement(statement)) {
      return normalizeSugaryArrayStatement(statement);
    } else {
      return normalizeVerboseStatement(statement);
    }
  } else if (typeof statement === 'string') {
    return {
      kind: HeadKind.AppendPath,
      path: normalizeDottedPath(statement),
      trusted: false,
    };
  } else {
    throw assertNever(statement);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / builder.ts View on Github external
let path = buildPath(normalized.path, ExpressionContext.BlockHead, symbols);

      return [[Op.Block, path, params, hash, blocks]];
    }

    case HeadKind.Element:
      return buildElement(normalized, symbols);

    case HeadKind.Modifier:
      throw unimpl('modifier');

    case HeadKind.DynamicComponent:
      throw unimpl('dynamic component');

    default:
      throw assertNever(normalized);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / opcode-compiler / lib / syntax / concat.ts View on Github external
} else if (action.type === 'Number') {
    pushOp(encoder, constants, action);
  } else if (action.type === 'Resolution') {
    pushResolutionOp(encoder, context, action, constants);
  } else if (action.type === 'Simple') {
    pushBuilderOp(context, action);
  } else if (action.type === 'Error') {
    encoder.error({
      problem: action.op1.problem,
      span: {
        start: action.op1.start,
        end: action.op1.end,
      },
    });
  } else {
    throw assertNever(action, 'unexpected action kind');
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / compiler / lib / wire-format-debug.ts View on Github external
return ['undefined'];

        case Op.Call:
          return [
            'call',
            this.formatOpcode(opcode[3]),
            this.formatParams(opcode[4]),
            this.formatHash(opcode[5]),
          ];

        case Op.Concat:
          return ['concat', this.formatParams(opcode[1] as WireFormat.Core.Params)];

        default: {
          let opName = opcode[0];
          throw assertNever(opName, `unexpected ${opName}`);
        }
      }
    } else {
      return opcode;
    }
  }