import type { ArrowInfo } from './Scope.mts'; import type { Character, UnicodeCharacter } from '#self'; export interface Position { /** 1-based */ readonly line: number; readonly column: number; } export interface Location { readonly startIndex: number; readonly endIndex: number; readonly start: Position; readonly end: Position; } export declare namespace ParseNode { export interface BaseParseNode { readonly type: ParseNode['type']; readonly location: Location; readonly strict: boolean; readonly sourceText: string; readonly parent: ParseNode | undefined; } export interface PrivateIdentifier extends BaseParseNode { readonly type: 'PrivateIdentifier'; readonly name: string; } export interface IdentifierName extends BaseParseNode { readonly type: 'IdentifierName'; readonly name: string; } export interface NullLiteral extends BaseParseNode { readonly type: 'NullLiteral'; } export interface BooleanLiteral extends BaseParseNode { readonly type: 'BooleanLiteral'; readonly value: boolean; } export interface NumericLiteral extends BaseParseNode { readonly type: 'NumericLiteral'; readonly value: number | bigint; } export interface StringLiteral extends BaseParseNode { readonly type: 'StringLiteral'; readonly value: string; } export interface RegularExpressionLiteral extends BaseParseNode { readonly type: 'RegularExpressionLiteral'; readonly RegularExpressionBody: string; readonly RegularExpressionFlags: string; } export interface IdentifierReference extends BaseParseNode { readonly type: 'IdentifierReference'; readonly escaped: boolean; readonly name: string; } export interface BindingIdentifier extends BaseParseNode { readonly type: 'BindingIdentifier'; readonly name: string; } export interface LabelIdentifier extends BaseParseNode { readonly type: 'LabelIdentifier'; readonly name: string; } export type PrimaryExpression = ThisExpression | IdentifierReference | Literal | ArrayLiteral | ObjectLiteral | FunctionExpression | ClassExpression | GeneratorExpression | AsyncFunctionExpression | AsyncGeneratorExpression | RegularExpressionLiteral | TemplateLiteral | CoverParenthesizedExpressionAndArrowParameterList | ParenthesizedExpression; export interface ThisExpression extends BaseParseNode { readonly type: 'ThisExpression'; } export interface CoverParenthesizedExpressionAndArrowParameterList extends BaseParseNode { readonly type: 'CoverParenthesizedExpressionAndArrowParameterList'; readonly Arguments: readonly (ArgumentListElement | BindingRestElement)[]; readonly arrowInfo?: ArrowInfo; } export interface ParenthesizedExpression extends BaseParseNode { readonly type: 'ParenthesizedExpression'; readonly Expression: Expression; } export type Literal = NullLiteral | BooleanLiteral | NumericLiteral | StringLiteral; export interface ArrayLiteral extends BaseParseNode { readonly type: 'ArrayLiteral'; readonly ElementList: ElementList; readonly hasTrailingComma: boolean; } export type ElementList = readonly ElementListElement[]; export type ElementListElement = AssignmentExpressionOrHigher | SpreadElement | Elision; export interface Elision extends BaseParseNode { readonly type: 'Elision'; } export interface SpreadElement extends BaseParseNode { readonly type: 'SpreadElement'; readonly AssignmentExpression: AssignmentExpressionOrHigher; } export interface ObjectLiteral extends BaseParseNode { readonly type: 'ObjectLiteral'; readonly PropertyDefinitionList: PropertyDefinitionList; } export type PropertyDefinitionList = readonly PropertyDefinitionLike[]; export type PropertyDefinitionLike = IdentifierReference | CoverInitializedName | PropertyDefinition | MethodDefinitionLike; export interface PropertyDefinition extends BaseParseNode { readonly type: 'PropertyDefinition'; readonly PropertyName: PropertyNameLike | null; readonly AssignmentExpression: AssignmentExpressionOrHigher; } export type PropertyNameLike = PropertyName | StringLiteral | NumericLiteral | IdentifierName; export interface PropertyName extends BaseParseNode { readonly type: 'PropertyName'; readonly ComputedPropertyName: AssignmentExpressionOrHigher; } export interface CoverInitializedName extends BaseParseNode { readonly type: 'CoverInitializedName'; readonly IdentifierReference: IdentifierReference; readonly Initializer: Initializer | null; } export type Initializer = AssignmentExpressionOrHigher; export interface TemplateLiteral extends BaseParseNode { readonly type: 'TemplateLiteral'; readonly TemplateSpanList: readonly string[]; readonly ExpressionList: readonly Expression[]; } export type MemberExpressionOrHigher = PrimaryExpression | MemberExpression | SuperProperty | MetaProperty | NewExpression; export interface MemberExpression extends BaseParseNode { readonly type: 'MemberExpression'; readonly MemberExpression: LeftHandSideExpression; readonly Expression: Expression | null; readonly IdentifierName: IdentifierName | null; readonly PrivateIdentifier: PrivateIdentifier | null; } export interface SuperProperty extends BaseParseNode { readonly type: 'SuperProperty'; readonly Expression: Expression | null; readonly IdentifierName: IdentifierName | null; } export type MetaProperty = NewTarget | ImportMeta; export interface NewTarget extends BaseParseNode { readonly type: 'NewTarget'; } export interface ImportMeta extends BaseParseNode { readonly type: 'ImportMeta'; } export type NewExpressionOrHigher = MemberExpressionOrHigher | NewExpression; export interface NewExpression extends BaseParseNode { readonly type: 'NewExpression'; readonly MemberExpression: LeftHandSideExpression; readonly Arguments: Arguments | null; } export type CallExpressionOrHigher = SuperCall | ImportCall | CallExpression | MemberExpression | TaggedTemplateExpression; export interface CallExpression extends BaseParseNode { readonly type: 'CallExpression'; readonly CallExpression: CallExpressionOrHigher | MemberExpressionOrHigher; readonly Arguments: Arguments; readonly arrowInfo?: ArrowInfo; } export interface TaggedTemplateExpression extends BaseParseNode { readonly type: 'TaggedTemplateExpression'; readonly MemberExpression: CallExpressionOrHigher | MemberExpressionOrHigher; readonly TemplateLiteral: TemplateLiteral; readonly arrowInfo?: ArrowInfo; } export interface SuperCall extends BaseParseNode { readonly type: 'SuperCall'; readonly Arguments: Arguments; } export interface ImportCall extends BaseParseNode { readonly type: 'ImportCall'; readonly Phase: 'source' | 'defer' | 'evaluation'; readonly AssignmentExpression: AssignmentExpressionOrHigher; readonly OptionsExpression?: AssignmentExpressionOrHigher; } export type Arguments = readonly ArgumentListElement[] & { readonly location: Location; }; export type ArgumentListElement = AssignmentExpressionOrHigher | AssignmentRestElement; export interface OptionalExpression extends BaseParseNode { readonly type: 'OptionalExpression'; readonly MemberExpression: MemberExpressionOrHigher | CallExpressionOrHigher | OptionalExpression; readonly OptionalChain: OptionalChain; } export interface OptionalChain extends BaseParseNode { readonly type: 'OptionalChain'; readonly OptionalChain: OptionalChain | null; readonly Arguments?: Arguments; readonly Expression?: Expression; readonly IdentifierName?: IdentifierName; readonly PrivateIdentifier?: PrivateIdentifier; } export type LeftHandSideExpression = NewExpressionOrHigher | CallExpressionOrHigher | OptionalExpression; export type UpdateExpressionOrHigher = LeftHandSideExpression | UpdateExpression; export interface UpdateExpression extends BaseParseNode { readonly type: 'UpdateExpression'; readonly operator: '++' | '--'; readonly LeftHandSideExpression: LeftHandSideExpression | null; readonly UnaryExpression: UnaryExpressionOrHigher | null; } export type UnaryExpressionOrHigher = UpdateExpressionOrHigher | UnaryExpression | AwaitExpression; export interface UnaryExpression extends BaseParseNode { readonly type: 'UnaryExpression'; readonly operator: 'delete' | 'void' | 'typeof' | '+' | '-' | '~' | '!'; readonly UnaryExpression: UnaryExpressionOrHigher; } export type ExponentiationExpressionOrHigher = UnaryExpressionOrHigher | ExponentiationExpression; export interface ExponentiationExpression extends BaseParseNode { readonly type: 'ExponentiationExpression'; readonly UpdateExpression: UpdateExpressionOrHigher; readonly ExponentiationExpression: ExponentiationExpressionOrHigher; } export type MultiplicativeExpressionOrHigher = ExponentiationExpressionOrHigher | MultiplicativeExpression; export interface MultiplicativeExpression extends BaseParseNode { readonly type: 'MultiplicativeExpression'; readonly MultiplicativeExpression: MultiplicativeExpressionOrHigher; readonly MultiplicativeOperator: MultiplicativeOperator; readonly ExponentiationExpression: ExponentiationExpressionOrHigher; } export type MultiplicativeOperator = '*' | '/' | '%'; export type AdditiveExpressionOrHigher = MultiplicativeExpressionOrHigher | AdditiveExpression; export interface AdditiveExpression extends BaseParseNode { readonly type: 'AdditiveExpression'; readonly operator: '+' | '-'; readonly AdditiveExpression: AdditiveExpressionOrHigher; readonly MultiplicativeExpression: MultiplicativeExpressionOrHigher; } export type ShiftExpressionOrHigher = AdditiveExpressionOrHigher | ShiftExpression; export interface ShiftExpression extends BaseParseNode { readonly type: 'ShiftExpression'; readonly operator: '<<' | '>>' | '>>>'; readonly ShiftExpression: ShiftExpressionOrHigher; readonly AdditiveExpression: AdditiveExpressionOrHigher; } export type RelationalExpressionOrHigher = ShiftExpressionOrHigher | RelationalExpression; export interface RelationalExpression extends BaseParseNode { readonly type: 'RelationalExpression'; readonly operator: '<' | '>' | '<=' | '>=' | 'instanceof' | 'in'; readonly PrivateIdentifier?: PrivateIdentifier; readonly RelationalExpression?: RelationalExpressionOrHigher; readonly ShiftExpression: ShiftExpressionOrHigher; } export type EqualityExpressionOrHigher = RelationalExpressionOrHigher | EqualityExpression; export interface EqualityExpression extends BaseParseNode { readonly type: 'EqualityExpression'; readonly operator: '==' | '!=' | '===' | '!=='; readonly EqualityExpression: EqualityExpressionOrHigher; readonly RelationalExpression: RelationalExpressionOrHigher; } export type BitwiseANDExpressionOrHigher = EqualityExpressionOrHigher | BitwiseANDExpression; export interface BitwiseANDExpression extends BaseParseNode { readonly type: 'BitwiseANDExpression'; readonly operator: '&'; readonly A: BitwiseANDExpressionOrHigher; readonly B: EqualityExpressionOrHigher; } export type BitwiseXORExpressionOrHigher = BitwiseANDExpressionOrHigher | BitwiseXORExpression; export interface BitwiseXORExpression extends BaseParseNode { readonly type: 'BitwiseXORExpression'; readonly operator: '^'; readonly A: BitwiseXORExpressionOrHigher; readonly B: BitwiseANDExpressionOrHigher; } export type BitwiseORExpressionOrHigher = BitwiseXORExpressionOrHigher | BitwiseORExpression; export interface BitwiseORExpression extends BaseParseNode { readonly type: 'BitwiseORExpression'; readonly operator: '|'; readonly A: BitwiseORExpressionOrHigher; readonly B: BitwiseXORExpressionOrHigher; } export type LogicalANDExpressionOrHigher = BitwiseORExpressionOrHigher | LogicalANDExpression; export interface LogicalANDExpression extends BaseParseNode { readonly type: 'LogicalANDExpression'; readonly LogicalANDExpression: LogicalANDExpressionOrHigher; readonly BitwiseORExpression: BitwiseORExpressionOrHigher; } export type LogicalORExpressionOrHigher = LogicalANDExpressionOrHigher | LogicalORExpression; export interface LogicalORExpression extends BaseParseNode { readonly type: 'LogicalORExpression'; readonly LogicalORExpression: LogicalORExpressionOrHigher; readonly LogicalANDExpression: LogicalANDExpressionOrHigher; } export interface CoalesceExpression extends BaseParseNode { readonly type: 'CoalesceExpression'; readonly CoalesceExpressionHead: CoalesceExpressionHead; readonly BitwiseORExpression: BitwiseORExpressionOrHigher; } export type CoalesceExpressionHead = BitwiseORExpressionOrHigher | CoalesceExpression; export type ShortCircuitExpressionOrHigher = LogicalORExpressionOrHigher | CoalesceExpression; export type ConditionalExpressionOrHigher = ShortCircuitExpressionOrHigher | ConditionalExpression; export interface ConditionalExpression extends BaseParseNode { readonly type: 'ConditionalExpression'; readonly ShortCircuitExpression: ShortCircuitExpressionOrHigher; readonly AssignmentExpression_a: AssignmentExpressionOrHigher; readonly AssignmentExpression_b: AssignmentExpressionOrHigher; } export type AssignmentExpressionOrHigher = ConditionalExpressionOrHigher | YieldExpression | ArrowFunction | AsyncArrowFunction | AssignmentExpression; export interface AssignmentExpression extends BaseParseNode { readonly type: 'AssignmentExpression'; readonly LeftHandSideExpression: AssignmentExpressionOrHigher; readonly AssignmentOperator: '=' | AssignmentOperator | '&&=' | '||=' | '??='; readonly AssignmentExpression: AssignmentExpressionOrHigher; } export type AssignmentOperator = '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|=' | '**='; export interface AssignmentRestElement extends BaseParseNode { readonly type: 'AssignmentRestElement'; readonly AssignmentExpression: AssignmentExpressionOrHigher; } export type BinaryExpressionOrHigher = BinaryExpression | UnaryExpressionOrHigher; export type BinaryExpression = AssignmentExpression | LogicalORExpression | LogicalANDExpression | BitwiseORExpression | BitwiseXORExpression | BitwiseANDExpression | RelationalExpression | EqualityExpression | ShiftExpression | AdditiveExpression | MultiplicativeExpression | ExponentiationExpression; export type Expression = CommaOperator | AssignmentExpressionOrHigher; export interface CommaOperator extends BaseParseNode { readonly type: 'CommaOperator'; readonly ExpressionList: readonly AssignmentExpressionOrHigher[]; } export type Statement = BlockStatement | VariableStatement | EmptyStatement | ExpressionStatement | IfStatement | BreakableStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement | LabelledStatement | ThrowStatement | TryStatement | DebuggerStatement; export type Declaration = HoistableDeclaration | ClassDeclaration | LexicalDeclarationLike; export type HoistableDeclaration = FunctionDeclaration | GeneratorDeclaration | AsyncFunctionDeclaration | AsyncGeneratorDeclaration; export type BreakableStatement = IterationStatement | SwitchStatement; export type BlockStatement = Block; export interface Block extends BaseParseNode { readonly type: 'Block'; readonly StatementList: StatementList; } export type StatementList = readonly StatementListItem[]; export type StatementListItem = Statement | Declaration; export type LexicalDeclarationLike = LexicalDeclaration; export interface LexicalDeclaration extends BaseParseNode { readonly type: 'LexicalDeclaration'; readonly LetOrConst: LetOrConst; readonly BindingList: BindingList; } export type LetOrConst = 'let' | 'const'; export type BindingList = readonly LexicalBinding[]; export interface LexicalBinding extends BaseParseNode { readonly type: 'LexicalBinding'; readonly BindingIdentifier?: BindingIdentifier; readonly BindingPattern?: BindingPattern; readonly Initializer: Initializer | null; } export interface VariableStatement extends BaseParseNode { readonly type: 'VariableStatement'; readonly VariableDeclarationList: VariableDeclarationList; } export type VariableDeclarationList = readonly VariableDeclaration[]; export interface VariableDeclaration extends BaseParseNode { readonly type: 'VariableDeclaration'; readonly BindingPattern?: BindingPattern; readonly BindingIdentifier?: BindingIdentifier; readonly Initializer: Initializer | null; } export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; export interface ObjectBindingPattern extends BaseParseNode { readonly type: 'ObjectBindingPattern'; readonly BindingPropertyList: BindingPropertyList; readonly BindingRestProperty?: BindingRestProperty; } export interface ArrayBindingPattern extends BaseParseNode { readonly type: 'ArrayBindingPattern'; readonly BindingElementList: BindingElementList; readonly BindingRestElement: BindingRestElement; } export interface BindingRestProperty extends BaseParseNode { readonly type: 'BindingRestProperty'; readonly BindingIdentifier: BindingIdentifier; } export type BindingPropertyList = readonly BindingPropertyLike[]; export type BindingElementList = readonly BindingElisionElement[]; export type BindingElisionElement = BindingElementLike | Elision; export type BindingPropertyLike = BindingProperty | SingleNameBinding; export interface BindingProperty extends BaseParseNode { readonly type: 'BindingProperty'; readonly PropertyName: PropertyNameLike; readonly BindingElement: BindingElementLike; } export type BindingElementLike = BindingElement | SingleNameBinding; export interface BindingElement extends BaseParseNode { readonly type: 'BindingElement'; readonly BindingPattern: BindingPattern; readonly Initializer: Initializer | null; } export interface SingleNameBinding extends BaseParseNode { readonly type: 'SingleNameBinding'; readonly BindingIdentifier: BindingIdentifier; readonly Initializer: Initializer | null; } export interface BindingRestElement extends BaseParseNode { readonly type: 'BindingRestElement'; readonly BindingIdentifier?: BindingIdentifier; readonly BindingPattern?: BindingPattern; } export interface EmptyStatement extends BaseParseNode { readonly type: 'EmptyStatement'; } export interface ExpressionStatement extends BaseParseNode { readonly type: 'ExpressionStatement'; readonly Expression: Expression; } export interface IfStatement extends BaseParseNode { readonly type: 'IfStatement'; readonly Expression: Expression; readonly Statement_a: Statement; readonly Statement_b: Statement; } export type IterationStatement = DoWhileStatement | WhileStatement | ForStatement | ForInOfStatement; export interface DoWhileStatement extends BaseParseNode { readonly type: 'DoWhileStatement'; readonly Statement: Statement; readonly Expression: Expression; } export interface WhileStatement extends BaseParseNode { readonly type: 'WhileStatement'; readonly Expression: Expression; readonly Statement: Statement; } export interface ForStatement extends BaseParseNode { readonly type: 'ForStatement'; readonly VariableDeclarationList: VariableDeclarationList; readonly LexicalDeclaration?: LexicalDeclarationLike; readonly Expression_a?: Expression; readonly Expression_b?: Expression; readonly Expression_c?: Expression; readonly Statement: Statement; } export type ForInOfStatement = ForInStatement | ForOfStatement | ForAwaitStatement; export interface ForInStatement extends BaseParseNode { readonly type: 'ForInStatement'; readonly LeftHandSideExpression?: LeftHandSideExpression; readonly ForBinding?: ForBinding; readonly ForDeclaration?: ForDeclarationLike; readonly Expression: Expression; readonly Statement: Statement; } export interface ForOfStatement extends BaseParseNode { readonly type: 'ForOfStatement'; readonly LeftHandSideExpression?: LeftHandSideExpression; readonly ForDeclaration?: ForDeclarationLike; readonly ForBinding?: ForBinding; readonly AssignmentExpression: AssignmentExpressionOrHigher; readonly Statement: Statement; } export interface ForAwaitStatement extends BaseParseNode { readonly type: 'ForAwaitStatement'; readonly LeftHandSideExpression?: LeftHandSideExpression; readonly ForDeclaration?: ForDeclarationLike; readonly ForBinding?: ForBinding; readonly AssignmentExpression: AssignmentExpressionOrHigher; readonly Statement: Statement; } export type ForDeclarationLike = ForDeclaration; export interface ForDeclaration extends BaseParseNode { readonly type: 'ForDeclaration'; readonly LetOrConst: LetOrConst; readonly ForBinding: ForBinding; } export interface ForBinding extends BaseParseNode { readonly type: 'ForBinding'; readonly BindingIdentifier?: BindingIdentifier; readonly BindingPattern?: BindingPattern; } export interface ContinueStatement extends BaseParseNode { readonly type: 'ContinueStatement'; readonly LabelIdentifier: LabelIdentifier | null; } export interface BreakStatement extends BaseParseNode { readonly type: 'BreakStatement'; readonly LabelIdentifier: LabelIdentifier | null; } export interface ReturnStatement extends BaseParseNode { readonly type: 'ReturnStatement'; readonly Expression: Expression | null; } export interface WithStatement extends BaseParseNode { readonly type: 'WithStatement'; readonly Expression: Expression; readonly Statement: Statement; } export interface SwitchStatement extends BaseParseNode { readonly type: 'SwitchStatement'; readonly Expression: Expression; readonly CaseBlock: CaseBlock; } export interface CaseBlock extends BaseParseNode { readonly type: 'CaseBlock'; readonly CaseClauses_a?: CaseClauses; readonly DefaultClause?: DefaultClause; readonly CaseClauses_b?: CaseClauses; } export type CaseClauses = readonly CaseClause[]; export interface CaseClause extends BaseParseNode { readonly type: 'CaseClause'; readonly Expression: Expression; readonly StatementList: StatementList; } export interface DefaultClause extends BaseParseNode { readonly type: 'DefaultClause'; readonly StatementList: StatementList; } export interface LabelledStatement extends BaseParseNode { readonly type: 'LabelledStatement'; readonly LabelIdentifier: LabelIdentifier; readonly LabelledItem: LabelledItem; } export type LabelledItem = Statement | FunctionDeclaration; export interface ThrowStatement extends BaseParseNode { readonly type: 'ThrowStatement'; readonly Expression: Expression; } export interface TryStatement extends BaseParseNode { readonly type: 'TryStatement'; readonly Block: Block; readonly Catch: Catch | null; readonly Finally: Finally | null; } export interface Catch extends BaseParseNode { readonly type: 'Catch'; readonly CatchParameter: CatchParameter | null; readonly Block: Block; } export type Finally = Block; export type CatchParameter = BindingPattern | BindingIdentifier; export interface DebuggerStatement extends BaseParseNode { readonly type: 'DebuggerStatement'; } export type UniqueFormalParameters = FormalParameters; export type FormalParameters = readonly FormalParametersElement[]; export type FormalParametersElement = FormalParameterList[number] | FunctionRestParameter; export type FormalParameterList = readonly FormalParameter[]; export type FunctionRestParameter = BindingRestElement; export type FormalParameter = BindingElementLike; export type FunctionLike = FunctionDeclarationLike | FunctionExpressionLike; export type FunctionDeclarationLike = FunctionDeclaration | GeneratorDeclaration | AsyncFunctionDeclaration | AsyncGeneratorDeclaration; export type FunctionExpressionLike = FunctionExpression | GeneratorExpression | AsyncFunctionExpression | AsyncGeneratorExpression; export type FunctionBodyLike = FunctionBody | GeneratorBody | AsyncBody | AsyncGeneratorBody; export interface FunctionDeclaration extends BaseParseNode { readonly type: 'FunctionDeclaration'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly FunctionBody: FunctionBody; } export interface FunctionExpression extends BaseParseNode { readonly type: 'FunctionExpression'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly FunctionBody: FunctionBody; } export interface FunctionBody extends BaseParseNode { readonly type: 'FunctionBody'; readonly directives: string[]; readonly strict: boolean; readonly FunctionStatementList: FunctionStatementList; } export type FunctionStatementList = StatementList; export interface ArrowFunction extends BaseParseNode { readonly type: 'ArrowFunction'; readonly ArrowParameters: ArrowParameters; readonly ConciseBody: ConciseBodyLike; } export type ArrowParameters = ArrowFormalParameters; export type ConciseBodyLike = FunctionBody | ConciseBody; export interface ConciseBody extends BaseParseNode { readonly type: 'ConciseBody'; readonly directives?: undefined; readonly ExpressionBody: ExpressionBody; } export interface ExpressionBody extends BaseParseNode { readonly type: 'ExpressionBody'; readonly AssignmentExpression: AssignmentExpressionOrHigher; } export type ArrowFormalParameters = UniqueFormalParameters; export interface AsyncArrowFunction extends BaseParseNode { readonly type: 'AsyncArrowFunction'; readonly ArrowParameters: ArrowParameters; readonly AsyncConciseBody: AsyncConciseBodyLike; } export type AsyncConciseBodyLike = AsyncConciseBody | AsyncBody; export interface AsyncConciseBody extends BaseParseNode { readonly type: 'AsyncConciseBody'; readonly directives?: undefined; readonly ExpressionBody: ExpressionBody; } export type MethodDefinitionLike = MethodDefinition | GeneratorMethod | AsyncMethod | AsyncGeneratorMethod; export interface MethodDefinition extends BaseParseNode { readonly type: 'MethodDefinition'; readonly Decorators?: readonly Decorator[] | null; readonly static?: boolean; readonly ClassElementName: ClassElementName; readonly PropertySetParameterList: PropertySetParameterList | null; readonly UniqueFormalParameters: UniqueFormalParameters | null; readonly FunctionBody: FunctionBody; } export type PropertySetParameterList = [FormalParameter]; export interface GeneratorDeclaration extends BaseParseNode { readonly type: 'GeneratorDeclaration'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly GeneratorBody: GeneratorBody; } export interface GeneratorExpression extends BaseParseNode { readonly type: 'GeneratorExpression'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly GeneratorBody: GeneratorBody; } export interface GeneratorMethod extends BaseParseNode { readonly type: 'GeneratorMethod'; readonly Decorators?: readonly Decorator[] | null; readonly static?: boolean; readonly ClassElementName: ClassElementName; readonly PropertySetParameterList: null; readonly UniqueFormalParameters: UniqueFormalParameters; readonly GeneratorBody: GeneratorBody; } export interface GeneratorBody extends BaseParseNode { readonly type: 'GeneratorBody'; readonly directives: string[]; readonly strict: boolean; readonly FunctionStatementList: FunctionStatementList; } export interface YieldExpression extends BaseParseNode { readonly type: 'YieldExpression'; readonly hasStar: boolean; readonly AssignmentExpression: AssignmentExpressionOrHigher | null; } export interface AsyncGeneratorDeclaration extends BaseParseNode { readonly type: 'AsyncGeneratorDeclaration'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly AsyncGeneratorBody: AsyncGeneratorBody; } export interface AsyncGeneratorExpression extends BaseParseNode { readonly type: 'AsyncGeneratorExpression'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly AsyncGeneratorBody: AsyncGeneratorBody; } export interface AsyncGeneratorMethod extends BaseParseNode { readonly type: 'AsyncGeneratorMethod'; readonly Decorators?: readonly Decorator[] | null; readonly static?: boolean; readonly ClassElementName: ClassElementName; readonly PropertySetParameterList: null; readonly UniqueFormalParameters: UniqueFormalParameters; readonly AsyncGeneratorBody: AsyncGeneratorBody; } export interface AsyncGeneratorBody extends BaseParseNode { readonly type: 'AsyncGeneratorBody'; readonly directives: string[]; readonly strict: boolean; readonly FunctionStatementList: FunctionStatementList; } export interface AsyncFunctionDeclaration extends BaseParseNode { readonly type: 'AsyncFunctionDeclaration'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly AsyncBody: AsyncBody; } export interface AsyncFunctionExpression extends BaseParseNode { readonly type: 'AsyncFunctionExpression'; readonly BindingIdentifier: BindingIdentifier | null; readonly FormalParameters: FormalParameters; readonly AsyncBody: AsyncBody; } export interface AsyncMethod extends BaseParseNode { readonly type: 'AsyncMethod'; readonly Decorators?: readonly Decorator[] | null; readonly static?: boolean; readonly ClassElementName: ClassElementName; readonly PropertySetParameterList: null; readonly UniqueFormalParameters: UniqueFormalParameters; readonly AsyncBody: AsyncBody; } export interface AsyncBody extends BaseParseNode { readonly type: 'AsyncBody'; readonly directives: string[]; readonly strict: boolean; readonly FunctionStatementList: FunctionStatementList; } export interface AwaitExpression extends BaseParseNode { readonly type: 'AwaitExpression'; readonly UnaryExpression: UnaryExpressionOrHigher; } export type ClassLike = ClassDeclaration | ClassExpression; export type Decorator = Decorator_MemberExpression | Decorator_ParenthesizedExpression | Decorator_CallExpression; export interface Decorator_MemberExpression extends BaseParseNode { readonly type: 'Decorator'; readonly subtype: 'MemberExpression'; readonly MemberExpression: MemberExpression | IdentifierReference; readonly ParenthesizedExpression?: undefined; readonly CallExpression?: undefined; } export interface Decorator_ParenthesizedExpression extends BaseParseNode { readonly type: 'Decorator'; readonly subtype: 'ParenthesizedExpression'; readonly ParenthesizedExpression: Expression; readonly MemberExpression?: undefined; readonly CallExpression?: undefined; } export interface Decorator_CallExpression extends BaseParseNode { readonly type: 'Decorator'; readonly subtype: 'CallExpression'; readonly CallExpression: CallExpression; readonly MemberExpression?: undefined; readonly ParenthesizedExpression?: undefined; } export interface ClassDeclaration extends BaseParseNode { readonly Decorators?: readonly Decorator[] | null; readonly type: 'ClassDeclaration'; readonly BindingIdentifier: BindingIdentifier | null; readonly ClassTail: ClassTail; } export interface ClassExpression extends BaseParseNode { readonly Decorators?: readonly Decorator[] | null; readonly type: 'ClassExpression'; readonly BindingIdentifier: BindingIdentifier | null; readonly ClassTail: ClassTail; } export interface ClassTail extends BaseParseNode { readonly type: 'ClassTail'; readonly ClassHeritage: ClassHeritage | null; readonly ClassBody: ClassBody | null; } export type ClassHeritage = LeftHandSideExpression; export type ClassBody = ClassElementList; export type ClassElementList = readonly ClassElement[]; export type ClassElement = MethodDefinitionLike | FieldDefinition | ClassStaticBlock; export interface FieldDefinition extends BaseParseNode { readonly Decorators?: readonly Decorator[] | null; readonly accessor?: boolean; readonly type: 'FieldDefinition'; readonly static?: boolean; readonly ClassElementName: ClassElementName; readonly Initializer: Initializer | null; } export type ClassElementName = PropertyNameLike | PrivateIdentifier; export interface ClassStaticBlock extends BaseParseNode { readonly type: 'ClassStaticBlock'; readonly static: true; readonly ClassStaticBlockBody: ClassStaticBlockBody; } export interface ClassStaticBlockBody extends BaseParseNode { readonly type: 'ClassStaticBlockBody'; readonly ClassStaticBlockStatementList: ClassStaticBlockStatementList; } export type ClassStaticBlockStatementList = StatementList; export interface Script extends BaseParseNode { readonly type: 'Script'; readonly ScriptBody: ScriptBody | null; } export interface ScriptBody extends BaseParseNode { readonly type: 'ScriptBody'; readonly StatementList: StatementList; } export interface Module extends BaseParseNode { readonly type: 'Module'; readonly ModuleBody: ModuleBody | null; readonly hasTopLevelAwait: boolean; } export interface ModuleBody extends BaseParseNode { readonly type: 'ModuleBody'; readonly ModuleItemList: ModuleItemList; } export type ModuleItemList = readonly ModuleItem[]; export type ModuleItem = ImportDeclaration | ExportDeclaration | StatementListItem; export type ModuleExportName = IdentifierName | StringLiteral; export interface ImportDeclaration extends BaseParseNode { readonly type: 'ImportDeclaration'; readonly ModuleSpecifier?: PrimaryExpression; readonly Phase: 'source' | 'defer' | 'evaluation'; readonly ImportClause?: ImportClause; readonly ImportedBinding?: ImportedBinding; readonly FromClause?: FromClause; readonly WithClause?: WithClause; } export interface ImportClause extends BaseParseNode { readonly type: 'ImportClause'; readonly ImportedDefaultBinding?: ImportedDefaultBinding; readonly NameSpaceImport?: NameSpaceImport; readonly NamedImports?: NamedImports; } export interface ImportedDefaultBinding extends BaseParseNode { readonly type: 'ImportedDefaultBinding'; readonly ImportedBinding: ImportedBinding; } export interface NameSpaceImport extends BaseParseNode { readonly type: 'NameSpaceImport'; readonly ImportedBinding: ImportedBinding; } export interface NamedImports extends BaseParseNode { readonly type: 'NamedImports'; readonly ImportsList: ImportsList; } export type FromClause = ModuleSpecifier; export type ImportsList = readonly ImportSpecifier[]; export interface ImportSpecifier extends BaseParseNode { readonly type: 'ImportSpecifier'; readonly ModuleExportName?: ModuleExportName; readonly ImportedBinding: ImportedBinding; } export type ModuleSpecifier = StringLiteral; export type ImportedBinding = BindingIdentifier; export interface WithClause extends BaseParseNode { readonly type: 'WithClause'; readonly WithEntries: WithEntries; } export type WithEntries = readonly WithEntry[]; export interface WithEntry extends BaseParseNode { readonly type: 'WithEntry'; readonly AttributeKey: AttributeKey; readonly AttributeValue: StringLiteral; } export type AttributeKey = IdentifierName | StringLiteral; export type ExportDeclaration = ExportDeclaration_Declaration | ExportDeclaration_DefaultClass | ExportDeclaration_DefaultDeclaration | ExportDeclaration_DefaultExpression | ExportDeclaration_NamedExports | ExportDeclaration_NamedFrom | ExportDeclaration_VariableStatement; export interface ExportDeclaration_NamedFrom extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly ExportFromClause: ExportFromClauseLike; readonly FromClause: FromClause; readonly WithClause: undefined | WithClause; readonly Phase: 'defer' | 'evaluation'; readonly AssignmentExpression?: undefined; readonly ClassDeclaration?: undefined; readonly Declaration?: null; readonly Decorators?: null; readonly default?: boolean; readonly HoistableDeclaration?: undefined; readonly NamedExports?: undefined; readonly VariableStatement?: undefined; } export interface ExportDeclaration_NamedExports extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly NamedExports: NamedExports; readonly AssignmentExpression?: undefined; readonly ClassDeclaration?: undefined; readonly Declaration?: null; readonly Decorators?: null; readonly default?: boolean; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly HoistableDeclaration?: undefined; readonly VariableStatement?: undefined; readonly WithClause?: undefined; } export interface ExportDeclaration_VariableStatement extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly VariableStatement: VariableStatement; readonly AssignmentExpression?: undefined; readonly ClassDeclaration?: undefined; readonly Declaration?: null; readonly Decorators?: null; readonly default?: boolean; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly HoistableDeclaration?: undefined; readonly NamedExports?: undefined; readonly WithClause?: undefined; } export interface ExportDeclaration_Declaration extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly Decorators: readonly Decorator[] | null; readonly Declaration: Declaration; readonly AssignmentExpression?: undefined; readonly ClassDeclaration?: undefined; readonly default?: boolean; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly HoistableDeclaration?: undefined; readonly NamedExports?: undefined; readonly VariableStatement?: undefined; readonly WithClause?: undefined; } export interface ExportDeclaration_DefaultDeclaration extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly default: true; readonly HoistableDeclaration: HoistableDeclaration; readonly AssignmentExpression?: undefined; readonly ClassDeclaration?: undefined; readonly Declaration?: null; readonly Decorators?: null; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly NamedExports?: undefined; readonly VariableStatement?: undefined; readonly WithClause?: undefined; } export interface ExportDeclaration_DefaultClass extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly Decorators: readonly Decorator[] | null; readonly default: true; readonly ClassDeclaration: ClassDeclaration; readonly AssignmentExpression?: undefined; readonly Declaration?: null; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly HoistableDeclaration?: undefined; readonly NamedExports?: undefined; readonly VariableStatement?: undefined; readonly WithClause?: undefined; } export interface ExportDeclaration_DefaultExpression extends BaseParseNode { readonly type: 'ExportDeclaration'; readonly default: true; readonly AssignmentExpression: AssignmentExpressionOrHigher; readonly ClassDeclaration?: undefined; readonly Declaration?: null; readonly Decorators?: null; readonly ExportFromClause?: undefined; readonly FromClause?: undefined; readonly HoistableDeclaration?: undefined; readonly NamedExports?: undefined; readonly VariableStatement?: undefined; readonly WithClause?: undefined; } export type ExportFromClauseLike = NamedExports | ExportFromClause; export interface ExportFromClause extends BaseParseNode { readonly type: 'ExportFromClause'; readonly ModuleExportName?: ModuleExportName; } export interface NamedExports extends BaseParseNode { readonly type: 'NamedExports'; readonly ExportsList: ExportsList; } export type ExportsList = readonly ExportSpecifier[]; export interface ExportSpecifier extends BaseParseNode { readonly type: 'ExportSpecifier'; readonly localName: ModuleExportName; readonly exportName: ModuleExportName; } export type AssignmentPattern = ObjectAssignmentPattern | ArrayAssignmentPattern | AssignmentProperty | AssignmentElement | ParseNode.Elision; export type ObjectAssignmentPattern = { type: 'ObjectAssignmentPattern'; AssignmentPropertyList: (AssignmentProperty | AssignmentPattern)[]; AssignmentRestProperty: AssignmentRestProperty | undefined; }; export type AssignmentProperty = { type: 'AssignmentProperty'; IdentifierReference: ParseNode.IdentifierReference; Initializer?: ParseNode.Initializer | null | undefined; } | { type: 'AssignmentProperty'; PropertyName: ParseNode.PropertyNameLike | null; AssignmentElement: AssignmentElement; }; export type AssignmentElement = { type: 'AssignmentElement'; DestructuringAssignmentTarget: ParseNode.AssignmentExpressionOrHigher; Initializer: ParseNode.Initializer | undefined | null; }; export type ArrayAssignmentPattern = { type: 'ArrayAssignmentPattern'; AssignmentElementList: AssignmentElisionElement[]; AssignmentRestElement: AssignmentRestElement | undefined; }; export type AssignmentElisionElement = ParseNode.Elision | AssignmentElement | AssignmentPattern; export type AssignmentRestProperty = { type: 'AssignmentRestProperty'; DestructuringAssignmentTarget: ParseNode.AssignmentExpressionOrHigher; }; type AllKeysOf = T extends unknown ? keyof T : never; type AllValuesOf> = T extends unknown ? K extends keyof T ? T[K] : never : never; /** * Used internally to describe a node that is still in the process of being parsed. Unfinished nodes may not yet be * fully defined. */ export type Unfinished = ({ type?: T['type'] & ParseNode['type']; location: { startIndex: number; endIndex: number; start: { line: number; column: number; }; end: { line: number; column: number; }; }; strict: boolean; sourceText: string; } & { -readonly [K in Exclude, 'location' | 'strict' | 'sourceText'>]?: AllValuesOf; }); /** * Used internally to indicate a node that has finished parsing. */ export type Finished, K extends T['type'] & ParseNode['type']> = T extends Unfinished ? Extract : T; export {}; } export declare namespace ParseNode { type WithStatementListChild = ModuleBody | ScriptBody | Block | CaseClause | DefaultClause | ClassStaticBlockBody | FunctionBody | GeneratorBody | AsyncBody | AsyncGeneratorBody; } /** https://tc39.es/ecma262/multipage/text-processing.html#sec-patterns */ export declare namespace ParseNode.RegExp { interface NodeWithPosition { readonly position: number; } interface Pattern { readonly type: 'Pattern'; readonly Disjunction: Disjunction; readonly capturingGroups: readonly { readonly GroupName: string | undefined; readonly position: number; }[]; } interface Disjunction { readonly type: 'Disjunction'; readonly Alternative: Alternative; readonly Disjunction: Disjunction | undefined; } interface Alternative { readonly type: 'Alternative'; readonly Term: readonly Term[]; } type Term = Term_Assertion | Term_Atom; interface Term_Assertion { readonly type: 'Term'; readonly production: 'Assertion'; readonly Assertion: Assertion; } interface Term_Atom { readonly type: 'Term'; readonly production: 'Atom'; readonly Atom: Atom; readonly Quantifier: Quantifier | undefined; readonly leftCapturingParenthesesBefore: number; readonly capturingParenthesesWithin: number; } type Assertion = Assertion_Plain | Assertion_LookaheadOrLookbehind; interface Assertion_Plain { readonly type: 'Assertion'; readonly production: '^' | '$' | 'b' | 'B' | 'A' | 'z'; } interface Assertion_LookaheadOrLookbehind { readonly type: 'Assertion'; readonly production: '?=' | '?!' | '?<=' | '?` which is often * more expensive and can complicate assignability checks. */ export type ParseNodesByType = { [N in ParseNode as N['type']]: N; }; //# sourceMappingURL=ParseNode.d.mts.map