type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
export function parseExpressionOps( parser: JSParser, context: ExpressionContext, noIn: undefined | boolean, refShorthandDefaultPos: IndexTracker, ): AnyExpression { const startPos = parser.state.startPos; const potentialArrowAt = parser.state.potentialArrowAt; const expr = parseMaybeUnary(parser, context, refS...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseExpressionOp( parser: JSParser, context: ExpressionContext, left: AnyExpression, leftStartPos: Position, minPrec: number, noIn: boolean = false, ): AnyExpression { if ( tt._in.getBinop() > minPrec && !parser.hasPrecedingLineBreak() && parser.isContextual("as") ) { const _const = tr...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse unary operators, both prefix and postfix. export function parseMaybeUnary( parser: JSParser, context: ExpressionContext, refShorthandDefaultPos?: IndexTracker, ): AnyExpression { if ( parser.isSyntaxEnabled("ts") && !parser.isSyntaxEnabled("jsx") && parser.isRelational("<") ) { return parseTSTypeA...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse call, dot, and `[]`-subscript expressions. export function parseExpressionWithPossibleSubscripts( parser: JSParser, context: ExpressionContext, refShorthandDefaultPos?: IndexTracker, ): AnyExpression { const startPos = parser.state.startPos; const potentialArrowAt = parser.state.potentialArrowAt; const e...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseSubscripts( parser: JSParser, base: AnyExpression, startPos: Position, noCalls?: boolean, ): AnyExpression { const maybeAsyncArrow = atPossibleAsync(parser, base); if ( base.type === "ReferenceIdentifier" && base.name === "async" && parser.state.noArrowAt.includes(startPos.index) ) {...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseAsyncArrowWithTypeParameters( parser: JSParser, startPos: Position, ): undefined | ArrowFunctionExpression { const {params, rest, typeParameters} = parseFunctionParams(parser); const {returnType, valid} = parseArrowHead(parser); if (!valid) { parser.addDiagnostic({ description: descript...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseExpressionSubscriptsRecursively( parser: JSParser, base: AnyExpression, startPos: Position, noCalls: undefined | boolean, maybeAsyncArrow: boolean, ): AnyExpression { const state: ParseSubscriptState = { optionalChainMember: false, stop: false, }; do { base = parseExpressionSubscript( pa...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseExpressionSubscript( parser: JSParser, base: AnyExpression, startPos: Position, noCalls: boolean = false, state: ParseSubscriptState, maybeAsyncArrow: boolean, ): AnyExpression { if (!parser.hasPrecedingLineBreak() && parser.match(tt.bang)) { parser.state.exprAllowed = false; parser.nex...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseTaggedTemplateExpression( parser: JSParser, startPos: Position, tag: AnyExpression, state: ParseSubscriptState, typeArguments?: TSTypeParameterInstantiation, ): TaggedTemplateExpression { if (state.optionalChainMember) { parser.addDiagnostic({ description: descriptions.JS_PARSER.TAGGED_...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function checkYieldAwaitInDefaultParams(parser: JSParser) { if ( ob1Get0(parser.state.yieldPos) > 0 && (parser.state.awaitPos === ob1Number0 || parser.state.yieldPos < parser.state.awaitPos) ) { parser.addDiagnostic({ index: parser.state.yieldPos, description: descriptions.JS_PARSER.YIELD_IN_GEN...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function atPossibleAsync(parser: JSParser, base: AnyExpression): boolean { const loc = parser.getLoc(base); return ( base.type === "ReferenceIdentifier" && base.name === "async" && parser.state.lastEndPos.index === loc.end.index && !parser.canInsertSemicolon() && parser.getRawInput(loc.start.index, ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseCallExpressionArguments( parser: JSParser, openContext: OpeningContext, possibleAsyncArrow: boolean, refTrailingCommaPos?: IndexTracker, ): { args: CallExpression["arguments"]; params: | undefined | Array<AnyExpression | SpreadElement | AmbiguousFlowTypeCastExpression>; } { let callArg...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function shouldParseAsyncArrow(parser: JSParser): boolean { return ( parser.match(tt.colon) || (parser.match(tt.arrow) && !parser.canInsertSemicolon()) ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseAsyncArrowFromCallExpression( parser: JSParser, start: Position, args: Array<AnyExpression | SpreadElement | AmbiguousFlowTypeCastExpression>, ): ArrowFunctionExpression { let returnType; if (parser.match(tt.colon)) { const oldNoAnonFunctionType = parser.state.noAnonFunctionType; parser....
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse a no-call expression (like argument of `new` or `::` operators). export function parseNoCallExpr( parser: JSParser, context: ExpressionContext, ): AnyExpression { const startPos = parser.state.startPos; return parseSubscripts( parser, parseExpressionAtom(parser, context), startPos, true, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseExpressionAtom( parser: JSParser, context: ExpressionContext, refShorthandDefaultPos?: IndexTracker, ): AnyExpression { // If a division operator appears in an expression position, the // tokenizer got confused, and we force it to read a regexp instead. if (parser.state.tokenType === tt.slas...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseBooleanLiteral(parser: JSParser): BooleanLiteral { const start = parser.getPosition(); const value = parser.match(tt._true); parser.next(); return parser.finishNode( start, { type: "BooleanLiteral", value, }, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseMaybePrivateName( parser: JSParser, ): PrivateName | Identifier { const isPrivate = parser.match(tt.hash); if (isPrivate) { const start = parser.getPosition(); parser.next(); parser.assertNoSpace(descriptions.JS_PARSER.SPACE_BETWEEN_PRIVATE_HASH); const id = parseIdentifier(parser, tru...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseFunctionExpressionOrMetaProperty( parser: JSParser, ): FunctionExpression | MetaProperty { const start = parser.getPosition(); parser.next(); // We do not do parseIdentifier here because when parseFunctionExpressionOrMetaProperty // is called we already know that the current token is a "nam...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseMetaProperty( parser: JSParser, start: Position, meta: Identifier, propertyName: string, ): MetaProperty { if ( meta.name === "function" && propertyName === "sent" && !parser.isContextual(propertyName) ) { // They didn't actually say `function.sent`, just `function.`, so a simple err...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseImportMetaProperty(parser: JSParser): MetaProperty { const start = parser.getPosition(); const id = parseIdentifier(parser, true); parser.expect(tt.dot); const node = parseMetaProperty(parser, start, id, "meta"); if (!parser.inModule) { parser.addDiagnostic({ loc: node.loc, descripti...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseParenExpression( parser: JSParser, context: ExpressionContext, ): AnyExpression { const openContext = parser.expectOpening(tt.parenL, tt.parenR, context); const val = parseExpression(parser, context); parser.expectClosing(openContext); return val; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseParenAndDistinguishExpression( parser: JSParser, context: ExpressionContext, canBeArrow: boolean, ): AnyExpression { if (parser.state.noArrowAt.includes(parser.state.startPos.index)) { canBeArrow = false; } const startPos = parser.state.startPos; const openContext = parser.expectOpening...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function shouldParseArrow(parser: JSParser): boolean { return parser.match(tt.colon) || !parser.canInsertSemicolon(); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseArrowHead( parser: JSParser, ): { valid: boolean; returnType: undefined | AnyTSPrimary; } { if (parser.match(tt.colon)) { const oldNoAnonFunctionType = parser.state.noAnonFunctionType; parser.state.noAnonFunctionType = true; const branch = parser.createBranch<undefined | AnyTSPrimary>()...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse a possible function param or call argument export function parseParenItem( parser: JSParser, node: AnyExpression | SpreadElement, startPos: Position, ): ToReferencedItem { let optional: undefined | boolean = undefined; if (parser.eat(tt.question)) { optional = true; } if (parser.match(tt.colon)) { ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseNew(parser: JSParser): NewExpression | MetaProperty { const start = parser.getPosition(); const meta = parseIdentifier(parser, true); if (parser.eat(tt.dot)) { const metaProp = parseMetaProperty(parser, start, meta, "target"); if (!parser.inScope("NON_ARROW_FUNCTION") && !parser.inScope("...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function getFirstOptionalChainMember( node: AnyNode, ): undefined | OptionalCallExpression | MemberExpression { if (node.type === "OptionalCallExpression") { return node; } if (node.type === "MemberExpression") { if (node.property.optional) { return node; } if (node.property.type === "StaticMemberProp...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse template expression. export function parseTemplateElement( parser: JSParser, isTagged: boolean, ): TemplateElement { const start = parser.getPosition(); const tokenValue = parser.state.tokenValue; if (tokenValue === undefined) { if (isTagged) { parser.state.invalidTemplateEscapePosition = undefined;...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseTemplate( parser: JSParser, isTagged: boolean, ): TemplateLiteral { const start = parser.getPosition(); const openContext = parser.expectOpening( tt.backQuote, tt.backQuote, "template literal", ); const expressions = []; let curElt = parseTemplateElement(parser, isTagged); const quas...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectExpression( parser: JSParser, refShorthandDefaultPos?: IndexTracker, ): ObjectExpression { const propHash: Set<string> = new Set(); let first = true; const start = parser.getPosition(); const properties = []; const openContext = parser.expectOpening(tt.braceL, tt.braceR, "object"); ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectPattern( parser: JSParser, refShorthandDefaultPos?: IndexTracker, ): BindingObjectPattern { const propHash: Set<string> = new Set(); let first = true; const start = parser.getPosition(); const properties: Array<BindingObjectPatternProperty> = []; let rest: undefined | BindingIdentifi...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function isGetterOrSetterMethod( parser: JSParser, key: StaticPropertyKey | ComputedPropertyKey, // `key` is always from `name.key`, we just need it here to refine keyVal: Identifier | AnyExpression | PrivateName, isPattern: boolean, ): keyVal is Identifier { return ( !isPattern && key.type === "Stati...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// get methods aren't allowed to have any parameters // set methods must have exactly 1 parameter export function checkGetterSetterParamCount( parser: JSParser, method: | ObjectMethod | ClassMethod | ClassPrivateMethod | TSDeclareFunction | TSDeclareMethod, kind: string, ): void { const head = method.hea...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectMethod( parser: JSParser, { key, start, isGenerator, isAsync, isPattern, escapePosition, }: ParseObjectMethodOpts, ): undefined | ObjectMethod { if (isAsync || isGenerator || parser.match(tt.parenL)) { if (isPattern) { parser.addDiagnostic({ description: descriptions...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectProperty( parser: JSParser, key: AnyObjectPropertyKey, start: Position, isPattern: boolean, refShorthandDefaultPos: undefined | IndexTracker, ): undefined | ObjectProperty | BindingObjectPatternProperty { if (parser.eat(tt.colon)) { if (isPattern) { const value = parseMaybeDefault...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectPropertyValue( parser: JSParser, { key, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos, escapePosition, }: ParseObjectPropValueOpts, ): undefined | ObjectMethod | ObjectProperty | BindingObjectPatternProperty { // parse type parameters for object method shor...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseObjectPropertyKey( parser: JSParser, ): StaticPropertyKey | ComputedPropertyKey { const start = parser.getPosition(); if (parser.match(tt.bracketL)) { const openContext = parser.expectOpening( tt.bracketL, tt.bracketR, "property name", ); const value = parseMaybeAssign(parser, ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse object or class method. export function parseMethod( parser: JSParser, opts: { kind: ClassMethodKind | ObjectMethodKind; isGenerator: boolean; isAsync: boolean; isConstructor: boolean; isClass: boolean; }, ): { head: FunctionHead; body: undefined | ParseFunctionBodyReturn["body"]; } { const {ki...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function createFunctionHead( parser: JSParser, params: Array<AnyBindingPattern>, rest: undefined | AnyTargetBindingPattern, opts: Partial<FunctionHead>, ): FunctionHead { const nonRestParams: FunctionHead["params"] = []; for (const param of params) { switch (param.type) { case "BindingIdentifier": case ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseArrowExpression( parser: JSParser, start: Position, opts: { bindingList?: Array<AnyBindingPattern>; assignmentList?: Array<ArrayHole | ToReferencedItem>; rest?: AnyTargetBindingPattern; }, isAsync: boolean = false, ): ArrowFunctionExpression { // if we got there, it's no more "yield in...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function isStrictBody(parser: JSParser, body: AnyNode): boolean { if (body.type === "BlockStatement" && body.directives !== undefined) { for (const directive of body.directives) { if (directive.value === "use strict") { return true; } } } return false; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseFunctionBodyAndFinish( parser: JSParser, opts: CheckFunctionNameParamsOpts & FunctionBodyParseOpts & { headStart: Position; }, ): { head: FunctionHead; body: undefined | ParseFunctionBodyReturn["body"]; } { let returnType = undefined; // For arrow functions, `parseArrow` handles the ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseFunctionBody( parser: JSParser, opts: FunctionBodyParseOpts, ): ParseFunctionBodyReturn { if (opts.isArrowFunction) { return forwardNoArrowParamsConversionAt( parser, opts.start, () => _parseFunctionBody(parser, opts), ); } else { return _parseFunctionBody(parser, opts); } }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse function body and check parameters. function _parseFunctionBody( parser: JSParser, opts: FunctionBodyParseOpts, ): ParseFunctionBodyReturn { const {isArrowFunction, isAsync, isGenerator} = opts; const isExpression = isArrowFunction && !parser.match(tt.braceL); parser.pushScope("PARAMETERS", false); par...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function checkFunctionNameAndParams( parser: JSParser, opts: CheckFunctionNameParamsOpts, body: AnyExpression | BlockStatement, force?: boolean, ): void { const {isArrowFunction, isMethod, id, rest, params, start} = opts; if ( !isSimpleParamList(params, rest) && body.type === "BlockStatement" && bo...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function isSimpleParamList( params: Array<AnyBindingPattern>, rest: undefined | AnyTargetBindingPattern, ): boolean { if (rest !== undefined) { return false; } for (const param of params) { if (param.type !== "BindingIdentifier") { return false; } } return true; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseExpressionList( parser: JSParser, context: ExpressionContext, openContext: OpeningContext, allowEmpty?: boolean, refShorthandDefaultPos?: IndexTracker, ): Array<ReturnType<typeof parseCallArgument>> { const elts = []; let first = true; while (true) { if (parser.match(openContext.close) ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseExpressionListNonEmpty( parser: JSParser, context: ExpressionContext, openContext: OpeningContext, refShorthandDefaultPos?: IndexTracker, ): Array<AnyExpression> { const val = parseExpressionList( parser, context, openContext, false, refShorthandDefaultPos, ); // @ts-ignore: Passe...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseCallArgument( parser: JSParser, context: ExpressionContext, allowHoles: boolean = false, refShorthandDefaultPos?: IndexTracker, refNeedsArrowPos?: IndexTracker, refTrailingCommaPos?: IndexTracker, ): ArrayHole | AnyExpression | SpreadElement | AmbiguousFlowTypeCastExpression { if (allowHole...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parse the next token as an identifier. If `liberal` is true (used // when parsing properties), it will also convert keywords into // identifiers. export function parseIdentifier(parser: JSParser, liberal?: boolean): Identifier { const start = parser.getPosition(); const name = parseIdentifierName(parser, liberal);...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseBindingIdentifier( parser: JSParser, liberal?: boolean, ): BindingIdentifier { return toBindingIdentifier(parser, parseIdentifier(parser, liberal)); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseReferenceIdentifier( parser: JSParser, liberal?: boolean, ): ReferenceIdentifier { return toReferenceIdentifier(parser, parseIdentifier(parser, liberal)); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function toBindingIdentifier( parser: JSParser, node: ReferenceIdentifier | Identifier | AssignmentIdentifier, ): BindingIdentifier { return parser.finalizeNode({ ...node, type: "BindingIdentifier", }); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function toAssignmentIdentifier( parser: JSParser, node: ReferenceIdentifier | Identifier | BindingIdentifier, ): AssignmentIdentifier { return parser.finalizeNode({ ...node, type: "AssignmentIdentifier", }); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function toReferenceIdentifier( parser: JSParser, node: BindingIdentifier | Identifier | AssignmentIdentifier, ): ReferenceIdentifier { return parser.finalizeNode({ ...node, type: "ReferenceIdentifier", }); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function toIdentifier( parser: JSParser, node: BindingIdentifier | ReferenceIdentifier | AssignmentIdentifier, ): Identifier { return { ...node, type: "Identifier", }; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function createIdentifier( parser: JSParser, start: Position, name: string, ): Identifier { const node: Identifier = parser.finishNode( start, { type: "Identifier", name, }, ); parser.getLoc(node).identifierName = name; return node; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseIdentifierName( parser: JSParser, liberal: boolean = false, ): string { const loc = parser.finishLocAt(parser.state.startPos, parser.state.endPos); if (!liberal) { checkReservedWord( parser, String(parser.state.tokenValue), loc, !!parser.state.tokenType.keyword, false, ); ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function checkReservedWord( parser: JSParser, word: string, loc: SourceLocation, checkKeywords: boolean, isBinding: boolean, ): void { if (parser.isSyntaxEnabled("ts")) { // TypeScript support in Babel disables reserved word checking... // This is mostly because TS allows reserved words in certain sce...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parses await expression inside async function. export function parseAwait(parser: JSParser): AwaitExpression { if (!parser.state.awaitPos) { parser.state.awaitPos = parser.state.index; } if (!parser.inScope("ASYNC")) { parser.addDiagnostic({ description: descriptions.JS_PARSER.AWAIT_OUTSIDE_ASYNC, }); ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
// Parses yield expression inside generator. export function parseYield(parser: JSParser, noIn?: boolean): YieldExpression { if (!parser.state.yieldPos) { parser.state.yieldPos = parser.state.index; } const start = parser.getPosition(); if (parser.inScope("PARAMETERS")) { parser.addDiagnostic({ start, d...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseNullLiteral(parser: JSParser): NullLiteral { const start = parser.getPosition(); parser.next(); return parser.finishNode(start, {type: "NullLiteral"}); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseStringLiteral(parser: JSParser): StringLiteral { const start = parser.getPosition(); const value = String(parser.state.tokenValue); parser.next(); return parser.finishNode( start, { type: "StringLiteral", value, }, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseBigIntLiteral(parser: JSParser): BigIntLiteral { const start = parser.getPosition(); const value = String(parser.state.tokenValue); parser.next(); return parser.finishNode( start, { type: "BigIntLiteral", value, }, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseNumericLiteral(parser: JSParser): NumericLiteral { const start = parser.getPosition(); const {tokenValue} = parser.state; if (!(tokenValue instanceof NumberTokenValue)) { throw new Error("Expected NumberTokenValue"); } const {value, format} = tokenValue; parser.next(); return parser.fini...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseRegExpLiteral(parser: JSParser): RegExpLiteral { const start = parser.getPosition(); const value = parser.state.tokenValue; if (!(value instanceof RegExpTokenValue)) { throw new Error("Expected regex token value"); } parser.next(); const {flags, pattern} = value; const regexParser = createRegE...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseImportOrMetaProperty(parser: JSParser): ImportCall | MetaProperty { if (parser.lookaheadState().tokenType === tt.dot) { return parseImportMetaProperty(parser); } else { return parseImportCall(parser); } }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseImportCall(parser: JSParser): ImportCall { parser.expect(tt._import); const start = parser.getPosition(); const openContext = parser.expectOpening(tt.parenL, tt.parenR, "array"); let argument: ReturnType<typeof parseCallArgument>; if (parser.match(tt.parenR)) { parser.addDiagnostic({ descrip...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseSuper(parser: JSParser): Super { if ( !parser.inScope("METHOD") && !parser.inScope("CLASS_PROPERTY") && parser.sourceType !== "template" ) { parser.addDiagnostic({ description: descriptions.JS_PARSER.SUPER_OUTSIDE_METHOD, }); } const start = parser.getPosition(); parser.next(); if ( ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseDoExpression(parser: JSParser): DoExpression { const start = parser.getPosition(); parser.next(); const oldLabels = parser.state.labels; parser.state.labels = []; parser.pushScope("FUNCTION", false); const body = parseBlock(parser, false); parser.popScope("FUNCTION"); parser.state.labels = oldLab...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
export function parseArrayHole(parser: JSParser): ArrayHole { return parser.finishNode( parser.getPosition(), { type: "ArrayHole", }, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
FunctionDeclaration
function parseArrayExpression( parser: JSParser, refShorthandDefaultPos?: IndexTracker, ): ArrayExpression { const start = parser.getPosition(); const openContext = parser.expectOpening(tt.bracketL, tt.bracketR, "array"); const elements = toReferencedListOptional( parser, parseExpressionList( parser, "...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { return _parseMaybeAssign( parser, context, noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { const start = parser.getPosition(); const typeParameters = parseTSTypeParameters(parser); const arrowExpression = forwardNoArrowParamsConversionAt( parser, start, () => _parseMaybeAssign<T>( parser, context, noIn, refShorthandDefaultPos, afterLeftParse, ...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => _parseMaybeAssign<T>( parser, context, noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos, )
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { return _parseMaybeAssign<T>( parser, context, noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos, ); }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { parser.state.noArrowParamsConversionAt.push(parser.state.startPos.index); const consequent = parseMaybeAssign(parser, "conditional consequent"); parser.state.noArrowParamsConversionAt.pop(); return { consequent, failed: !parser.match(tt.colon), }; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => _parseConditional(parser, expr, noIn, startPos)
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => parseMaybeAssign( parser, "conditional alternate", noIn, undefined, undefined, undefined, )
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => parseAsyncArrowWithTypeParameters(parser, startPos)
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => parseExpressionSubscriptsRecursively( parser, base, startPos, noCalls, maybeAsyncArrow, )
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { const typeArguments = parseTSTypeArguments(parser); if (!noCalls && parser.match(tt.parenL)) { const argsStart = parser.getPosition(); const openContext = parser.expectOpening( tt.parenL, tt.parenR, "call arguments", ); const {args} = parseCallExpressionArguments(parser, o...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => { const res = parseTSTypeOrTypePredicateAnnotation(parser, tt.colon); if (parser.canInsertSemicolon()) { // No semicolon insertion expected return undefined; } if (parser.eat(tt.arrow)) { return res; } return undefined; }
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ArrowFunction
() => _parseFunctionBody(parser, opts)
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type MaybeAssignAfterParse<T> = ( parser: JSParser, left: AnyExpression, startPos: Position, ) => T;
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type ParseSubscriptState = { stop: boolean; optionalChainMember: boolean; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type ExpressionContext = | "await argument" | "export default declaration" | "export from" | "import source" | "return argument" | "switch discriminant" | "case test" | "throw argument" | "flow object property key" | "flow declare module id" | "flow declared predicate" | "class private property" | "class...
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type ParseObjectMethodOpts = { key: AnyObjectPropertyKey; start: Position; isGenerator: boolean; isAsync: boolean; isPattern: boolean; escapePosition: undefined | Number0; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type ParseObjectPropValueOpts = { key: ComputedPropertyKey | StaticPropertyKey; start: Position; isGenerator: boolean; isAsync: boolean; isPattern: boolean; refShorthandDefaultPos: undefined | IndexTracker; escapePosition: undefined | Number0; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type FunctionBodyParseOpts = { allowBodiless: boolean; isArrowFunction: boolean; isAsync: boolean; isGenerator: boolean; isMethod: boolean; start: Position; id: BindingIdentifier | undefined; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type ParseFunctionBodyReturn = { body: BlockStatement | AnyExpression; hasHoistedVars: boolean; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
TypeAliasDeclaration
type CheckFunctionNameParamsOpts = { isArrowFunction: boolean; isMethod: boolean; id: undefined | BindingIdentifier; params: Array<AnyBindingPattern>; rest: undefined | AnyTargetBindingPattern; start: Position; };
halfnelson/rome
packages/@romejs/js-parser/parser/expression.ts
TypeScript
ClassDeclaration
@Component({ selector: "hb-footer", templateUrl: "./footer.component.html", styleUrls: ["./footer.component.scss"] }) export class FooterComponent implements OnInit { constructor() {} ngOnInit(): void {} getYear() { const date = new Date(); return date.getFullYear(); } }
lucasgmagalhaes/hubook
web/src/app/presentation/footer/footer.component.ts
TypeScript
MethodDeclaration
getYear() { const date = new Date(); return date.getFullYear(); }
lucasgmagalhaes/hubook
web/src/app/presentation/footer/footer.component.ts
TypeScript
FunctionDeclaration
/** * Copyright 2021 Solomon Shalom Lijo. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or...
solomonshalom/virtual-event-starter-kit
components/ticket-mono.tsx
TypeScript
InterfaceDeclaration
export interface IExtensionDialogProps { props?: any, onSubmit: (props: any | null) => any, open: boolean }
edwardkarak/cms
src/modules/editor/components/extensions/dialogs.tsx
TypeScript
FunctionDeclaration
export function register(config?: Config) { if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL( (process as { readonly env: { readonly [key: string]: string } }).env.PUBLIC_URL, ...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
FunctionDeclaration
function registerValidSW(swUrl: string, config?: Config) { navigator.serviceWorker .register(swUrl) .then(registration => { registration.onupdatefound = () => { const installingWorker = registration.installing if (installingWorker == null) { return } installing...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript
FunctionDeclaration
function checkValidServiceWorker(swUrl: string, config?: Config) { // Check if the service worker can be found. If it can't reload the page. fetch(swUrl) .then(response => { // Ensure service worker exists, and that we really are getting a JS file. const contentType = response.headers.get("content-...
ohlookasquirrel/react-seed-project
src/serviceWorker.ts
TypeScript