From 89b1969f02c0e472bfaa5ec36a07ed71fad8d9cb Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 6 Feb 2025 21:45:45 +0100 Subject: [PATCH 1/6] feat(unstable): add lint plugin ast types (#27977) Add type definition for all TSEstree AST nodes in the JS lint plugin system --- cli/tsc/dts/lib.deno.unstable.d.ts | 2354 ++++++++++++++++++++++++++++ 1 file changed, 2354 insertions(+) diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 8113f75809db0d..c013295b865ad3 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1475,6 +1475,2360 @@ declare namespace Deno { fileName: string, source: string, ): Diagnostic[]; + + /** + * @category Linter + * @experimental + */ + export interface ImportSpecifier { + type: "ImportSpecifier"; + range: [number, number]; + imported: Identifier | StringLiteral; + local: Identifier; + importKind: "type" | "value"; + } + + /** + * @category Linter + * @experimental + */ + export interface ImportDefaultSpecifier { + type: "ImportDefaultSpecifier"; + range: [number, number]; + local: Identifier; + } + + /** + * @category Linter + * @experimental + */ + export interface ImportNamespaceSpecifier { + type: "ImportNamespaceSpecifier"; + range: [number, number]; + local: Identifier; + } + + /** + * @category Linter + * @experimental + */ + export interface ImportAttribute { + type: "ImportAttribute"; + range: [number, number]; + key: Identifier | Literal; + value: Literal; + } + + /** + * An import declaration, examples: + * @category Linter + * @experimental + */ + export interface ImportDeclaration { + type: "ImportDeclaration"; + range: [number, number]; + importKind: "type" | "value"; + source: StringLiteral; + specifiers: Array< + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportSpecifier + >; + attributes: ImportAttribute[]; + } + + /** + * @category Linter + * @experimental + */ + export interface ExportDefaultDeclaration { + type: "ExportDefaultDeclaration"; + range: [number, number]; + declaration: + | ClassDeclaration + | Expression + | FunctionDeclaration + | TSDeclareFunction + | TSEnumDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration; + exportKind: "type" | "value"; + } + + /** + * @category Linter + * @experimental + */ + export interface ExportNamedDeclaration { + type: "ExportNamedDeclaration"; + range: [number, number]; + exportKind: "type" | "value"; + specifiers: ExportSpecifier[]; + declaration: + | ClassDeclaration + | FunctionDeclaration + | TSDeclareFunction + | TSEnumDeclaration + | TSImportEqualsDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration + | null; + source: StringLiteral | null; + attributes: ImportAttribute[]; + } + + /** + * @category Linter + * @experimental + */ + export interface ExportAllDeclaration { + type: "ExportAllDeclaration"; + range: [number, number]; + exportKind: "type" | "value"; + exported: Identifier | null; + source: StringLiteral; + attributes: ImportAttribute[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNamespaceExportDeclaration { + type: "TSNamespaceExportDeclaration"; + range: [number, number]; + id: Identifier; + } + + /** + * @category Linter + * @experimental + */ + export interface TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration"; + range: [number, number]; + importKind: "type" | "value"; + id: Identifier; + moduleReference: Identifier | TSExternalModuleReference | TSQualifiedName; + } + + /** + * @category Linter + * @experimental + */ + export interface TSExternalModuleReference { + type: "TSExternalModuleReference"; + range: [number, number]; + expression: StringLiteral; + } + + /** + * @category Linter + * @experimental + */ + export interface ExportSpecifier { + type: "ExportSpecifier"; + range: [number, number]; + exportKind: "type" | "value"; + exported: Identifier | StringLiteral; + local: Identifier | StringLiteral; + } + + /** + * Variable declaration. + * @category Linter + * @experimental + */ + export interface VariableDeclaration { + type: "VariableDeclaration"; + range: [number, number]; + declare: boolean; + kind: "let" | "var" | "const" | "await using" | "using"; + declarations: VariableDeclarator[]; + } + + /** + * A VariableDeclaration can declare multiple variables. This node + * represents a single declaration out of that. + * @category Linter + * @experimental + */ + export interface VariableDeclarator { + type: "VariableDeclarator"; + range: [number, number]; + id: ArrayPattern | ObjectPattern | Identifier; + init: Expression | null; + definite: boolean; + } + + /** + * Function/Method parameter + * @category Linter + * @experimental + */ + export type Parameter = + | ArrayPattern + | AssignmentPattern + | Identifier + | ObjectPattern + | RestElement + | TSParameterProperty; + + /** + * TypeScript accessibility modifiers used in classes + * @category Linter + * @experimental + */ + export type Accessibility = "private" | "protected" | "public"; + + /** + * Declares a function in the current scope + * @category Linter + * @experimental + */ + export interface FunctionDeclaration { + type: "FunctionDeclaration"; + range: [number, number]; + declare: boolean; + async: boolean; + generator: boolean; + id: Identifier | null; + typeParameters: TSTypeParameterDeclaration | undefined; + returnType: TSTypeAnnotation | undefined; + body: BlockStatement | null; + params: Parameter[]; + } + + /** + * Experimental: Decorators + * @category Linter + * @experimental + */ + export interface Decorator { + type: "Decorator"; + range: [number, number]; + expression: + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | CallExpression + | ClassExpression + | FunctionExpression + | Identifier + | JSXElement + | JSXFragment + | Literal + | TemplateLiteral + | MemberExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | SequenceExpression + | Super + | TaggedTemplateExpression + | ThisExpression + | TSAsExpression + | TSNonNullExpression + | TSTypeAssertion; + } + + /** + * Declares a class in the current scope + * @category Linter + * @experimental + */ + export interface ClassDeclaration { + type: "ClassDeclaration"; + range: [number, number]; + declare: boolean; + abstract: boolean; + id: Identifier | null; + superClass: + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | CallExpression + | ClassExpression + | FunctionExpression + | Identifier + | JSXElement + | JSXFragment + | Literal + | TemplateLiteral + | MemberExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | SequenceExpression + | Super + | TaggedTemplateExpression + | ThisExpression + | TSAsExpression + | TSNonNullExpression + | TSTypeAssertion + | null; + implements: TSClassImplements[]; + body: ClassBody; + } + + /** + * Similar to ClassDeclaration but for declaring a class as an + * expression. The main difference is that the class name(=id) can + * be omitted. + * @category Linter + * @experimental + */ + export interface ClassExpression { + type: "ClassExpression"; + range: [number, number]; + declare: boolean; + abstract: boolean; + id: Identifier | null; + superClass: + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | CallExpression + | ClassExpression + | FunctionExpression + | Identifier + | JSXElement + | JSXFragment + | Literal + | TemplateLiteral + | MemberExpression + | MetaProperty + | ObjectExpression + | ObjectPattern + | SequenceExpression + | Super + | TaggedTemplateExpression + | ThisExpression + | TSAsExpression + | TSNonNullExpression + | TSTypeAssertion + | null; + superTypeArguments: TSTypeParameterInstantiation | undefined; + typeParameters: TSTypeParameterDeclaration | undefined; + implements: TSClassImplements[]; + body: ClassBody; + } + + /** + * Represents the body of a class and contains all members + * @category Linter + * @experimental + */ + export interface ClassBody { + type: "ClassBody"; + range: [number, number]; + body: Array< + | AccessorProperty + | MethodDefinition + | PropertyDefinition + | StaticBlock + // Stage 1 Proposal: + // https://github.com/tc39/proposal-grouped-and-auto-accessors + // | TSAbstractAccessorProperty + | TSAbstractMethodDefinition + | TSAbstractPropertyDefinition + | TSIndexSignature + >; + } + + /** + * Static class initializiation block. + * @category Linter + * @experimental + */ + export interface StaticBlock { + type: "StaticBlock"; + range: [number, number]; + body: Statement[]; + } + + // Stage 1 Proposal: + // https://github.com/tc39/proposal-grouped-and-auto-accessors + // | TSAbstractAccessorProperty + /** + * @category Linter + * @experimental + */ + export interface AccessorProperty { + type: "AccessorProperty"; + range: [number, number]; + declare: boolean; + computed: boolean; + optional: boolean; + override: boolean; + readonly: boolean; + static: boolean; + accessibility: Accessibility | undefined; + decorators: Decorator[]; + key: Expression | Identifier | NumberLiteral | StringLiteral; + value: Expression | null; + } + + /** + * @category Linter + * @experimental + */ + export interface PropertyDefinition { + type: "PropertyDefinition"; + range: [number, number]; + declare: boolean; + computed: boolean; + optional: boolean; + override: boolean; + readonly: boolean; + static: boolean; + accessibility: Accessibility | undefined; + decorators: Decorator[]; + key: Expression | Identifier | NumberLiteral | StringLiteral; + value: Expression | null; + typeAnnotation: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface MethodDefinition { + type: "MethodDefinition"; + range: [number, number]; + declare: boolean; + computed: boolean; + optional: boolean; + override: boolean; + readonly: boolean; + static: boolean; + kind: "constructor" | "get" | "method" | "set"; + accessibility: Accessibility | undefined; + decorators: Decorator[]; + key: + | PrivateIdentifier + | Identifier + | NumberLiteral + | StringLiteral + | Expression; + value: FunctionExpression | TSEmptyBodyFunctionExpression; + } + + /** + * @category Linter + * @experimental + */ + export interface BlockStatement { + type: "BlockStatement"; + range: [number, number]; + body: Statement[]; + } + + /** + * The `debugger;` statement. + * @category Linter + * @experimental + */ + export interface DebuggerStatement { + type: "DebuggerStatement"; + range: [number, number]; + } + + /** + * Legacy JavaScript feature, that's discouraged from being used today. + * @deprecated + * @category Linter + * @experimental + */ + export interface WithStatement { + type: "WithStatement"; + range: [number, number]; + object: Expression; + body: Statement; + } + + /** + * Returns a value from a function. + * @category Linter + * @experimental + */ + export interface ReturnStatement { + type: "ReturnStatement"; + range: [number, number]; + argument: Expression | null; + } + + /** + * Custom control flow based on labels. + * @category Linter + * @experimental + */ + export interface LabeledStatement { + type: "LabeledStatement"; + range: [number, number]; + label: Identifier; + body: Statement; + } + + /** + * Break any loop or labeled statement, example: + * + * ```ts + * while (true) { + * break; + * } + * + * for (let i = 0; i < 10; i++) { + * if (i > 5) break; + * } + * ``` + * @category Linter + * @experimental + */ + export interface BreakStatement { + type: "BreakStatement"; + range: [number, number]; + label: Identifier | null; + } + + /** + * Terminates the current loop and continues with the next iteration. + * @category Linter + * @experimental + */ + export interface ContinueStatement { + type: "ContinueStatement"; + range: [number, number]; + label: Identifier | null; + } + + /** + * Execute a statement the test passes, otherwise the alternate + * statement, if it was defined. + * @category Linter + * @experimental + */ + export interface IfStatement { + type: "IfStatement"; + range: [number, number]; + test: Expression; + consequent: Statement; + alternate: Statement | null; + } + + /** + * Match an expression against a series of cases. + * @category Linter + * @experimental + */ + export interface SwitchStatement { + type: "SwitchStatement"; + range: [number, number]; + discriminant: Expression; + cases: SwitchCase[]; + } + + /** + * A single case of a SwitchStatement. + * @category Linter + * @experimental + */ + export interface SwitchCase { + type: "SwitchCase"; + range: [number, number]; + test: Expression | null; + consequent: Statement[]; + } + + /** + * Throw a user defined exception. Stops execution + * of the current function. + * @category Linter + * @experimental + */ + export interface ThrowStatement { + type: "ThrowStatement"; + range: [number, number]; + argument: Expression; + } + + /** + * Run a loop while the test expression is truthy. + * @category Linter + * @experimental + */ + export interface WhileStatement { + type: "WhileStatement"; + range: [number, number]; + test: Expression; + body: Statement; + } + + /** + * Re-run loop for as long as test expression is truthy. + * @category Linter + * @experimental + */ + export interface DoWhileStatement { + type: "DoWhileStatement"; + range: [number, number]; + test: Expression; + body: Statement; + } + + /** + * Classic for-loop. + * @category Linter + * @experimental + */ + export interface ForStatement { + type: "ForStatement"; + range: [number, number]; + init: Expression | VariableDeclaration | null; + test: Expression | null; + update: Expression | null; + body: Statement; + } + + /** + * Enumerate over all enumerable string properties of an object. + * @category Linter + * @experimental + */ + export interface ForInStatement { + type: "ForInStatement"; + range: [number, number]; + left: Expression | VariableDeclaration; + right: Expression; + body: Statement; + } + + /** + * Iterate over sequence of values from an iterator. + * @category Linter + * @experimental + */ + export interface ForOfStatement { + type: "ForOfStatement"; + range: [number, number]; + await: boolean; + left: Expression | VariableDeclaration; + right: Expression; + body: Statement; + } + + /** + * Statement that holds an expression. + * @category Linter + * @experimental + */ + export interface ExpressionStatement { + type: "ExpressionStatement"; + range: [number, number]; + expression: Expression; + } + + /** + * Try/catch statement + * @category Linter + * @experimental + */ + export interface TryStatement { + type: "TryStatement"; + range: [number, number]; + block: BlockStatement; + handler: CatchClause | null; + finalizer: BlockStatement | null; + } + + /** + * The catch clause of a try/catch statement + * @category Linter + * @experimental + */ + export interface CatchClause { + type: "CatchClause"; + range: [number, number]; + param: ArrayPattern | ObjectPattern | Identifier | null; + body: BlockStatement; + } + + /** + * An array literal + * @category Linter + * @experimental + */ + export interface ArrayExpression { + type: "ArrayExpression"; + range: [number, number]; + elements: Array; + } + + /** + * An object literal. + * @category Linter + * @experimental + */ + export interface ObjectExpression { + type: "ObjectExpression"; + range: [number, number]; + properties: Array; + } + + /** + * Compare left and right value with the specifier operator. + * @category Linter + * @experimental + */ + export interface BinaryExpression { + type: "BinaryExpression"; + range: [number, number]; + operator: + | "&" + | "**" + | "*" + | "||" + | "|" + | "^" + | "===" + | "==" + | "!==" + | "!=" + | ">=" + | ">>>" + | ">>" + | ">" + | "in" + | "instanceof" + | "<=" + | "<<" + | "<" + | "-" + | "%" + | "+" + | "/"; + left: Expression | PrivateIdentifier; + right: Expression; + } + + /** + * Chain expressions based on the operator specified + * @category Linter + * @experimental + */ + export interface LogicalExpression { + type: "LogicalExpression"; + range: [number, number]; + operator: "&&" | "??" | "||"; + left: Expression; + right: Expression; + } + + /** + * Declare a function as an expression. Similar to `FunctionDeclaration`, + * with an optional name (=id). + * @category Linter + * @experimental + */ + export interface FunctionExpression { + type: "FunctionExpression"; + range: [number, number]; + async: boolean; + generator: boolean; + id: Identifier | null; + typeParameters: TSTypeParameterDeclaration | undefined; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + body: BlockStatement; + } + + /** + * Arrow function expression + * @category Linter + * @experimental + */ + export interface ArrowFunctionExpression { + type: "ArrowFunctionExpression"; + range: [number, number]; + async: boolean; + generator: boolean; + id: null; + typeParameters: TSTypeParameterDeclaration | undefined; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + body: BlockStatement | Expression; + } + + /** + * The `this` keyword used in classes. + * @category Linter + * @experimental + */ + export interface ThisExpression { + type: "ThisExpression"; + range: [number, number]; + } + + /** + * The `super` keyword used in classes. + * @category Linter + * @experimental + */ + export interface Super { + type: "Super"; + range: [number, number]; + } + + /** + * Apply operand on value based on the specified operator. + * @category Linter + * @experimental + */ + export interface UnaryExpression { + type: "UnaryExpression"; + range: [number, number]; + operator: "!" | "+" | "~" | "-" | "delete" | "typeof" | "void"; + argument: Expression; + } + + /** + * Create a new instance of a class. + * @category Linter + * @experimental + */ + export interface NewExpression { + type: "NewExpression"; + range: [number, number]; + callee: Expression; + typeArguments: TSTypeParameterInstantiation | undefined; + arguments: Array; + } + + /** + * Dynamically import a module. + * @category Linter + * @experimental + */ + export interface ImportExpression { + type: "ImportExpression"; + range: [number, number]; + source: Expression; + options: Expression | null; + } + + /** + * A function call. + * @category Linter + * @experimental + */ + export interface CallExpression { + type: "CallExpression"; + range: [number, number]; + optional: boolean; + callee: Expression; + typeArguments: TSTypeParameterInstantiation | null; + arguments: Array; + } + + /** + * Syntactic sugar to increment or decrement a value. + * @category Linter + * @experimental + */ + export interface UpdateExpression { + type: "UpdateExpression"; + range: [number, number]; + prefix: boolean; + operator: "++" | "--"; + argument: Expression; + } + + /** + * Updaate a variable or property. + * @category Linter + * @experimental + */ + export interface AssignmentExpression { + type: "AssignmentExpression"; + range: [number, number]; + operator: + | "&&=" + | "&=" + | "**=" + | "*=" + | "||=" + | "|=" + | "^=" + | "=" + | ">>=" + | ">>>=" + | "<<=" + | "-=" + | "%=" + | "+=" + | "??=" + | "/="; + left: Expression; + right: Expression; + } + + /** + * Inline if-statement. + * @category Linter + * @experimental + */ + export interface ConditionalExpression { + type: "ConditionalExpression"; + range: [number, number]; + test: Expression; + consequent: Expression; + alternate: Expression; + } + + /** + * MemberExpression + * @category Linter + * @experimental + */ + export interface MemberExpression { + type: "MemberExpression"; + range: [number, number]; + optional: boolean; + computed: boolean; + object: Expression; + property: Expression | Identifier | PrivateIdentifier; + } + + /** + * ChainExpression + * @category Linter + * @experimental + */ + export interface ChainExpression { + type: "ChainExpression"; + range: [number, number]; + expression: + | CallExpression + | MemberExpression + | TSNonNullExpression; + } + + /** + * Execute multiple expressions in sequence. + * @category Linter + * @experimental + */ + export interface SequenceExpression { + type: "SequenceExpression"; + range: [number, number]; + expressions: Expression[]; + } + + /** + * A template literal string. + * @category Linter + * @experimental + */ + export interface TemplateLiteral { + type: "TemplateLiteral"; + range: [number, number]; + quasis: TemplateElement[]; + expressions: Expression[]; + } + + /** + * The static portion of a template literal. + * @category Linter + * @experimental + */ + export interface TemplateElement { + type: "TemplateElement"; + range: [number, number]; + tail: boolean; + raw: string; + cooked: string; + } + + /** + * Tagged template expression. + * @category Linter + * @experimental + */ + export interface TaggedTemplateExpression { + type: "TaggedTemplateExpression"; + range: [number, number]; + tag: Expression; + typeArguments: TSTypeParameterInstantiation | undefined; + quasi: TemplateLiteral; + } + + /** + * Pause or resume a generator function. + * @category Linter + * @experimental + */ + export interface YieldExpression { + type: "YieldExpression"; + range: [number, number]; + delegate: boolean; + argument: Expression | null; + } + + /** + * Await a `Promise` and get its fulfilled value. + * @category Linter + * @experimental + */ + export interface AwaitExpression { + type: "AwaitExpression"; + range: [number, number]; + argument: Expression; + } + + /** + * Can either be `import.meta` or `new.target`. + * @category Linter + * @experimental + */ + export interface MetaProperty { + type: "MetaProperty"; + range: [number, number]; + meta: Identifier; + property: Identifier; + } + + /** + * Custom named node by the developer. Can be a variable name, + * a function name, parameter, etc. + * @category Linter + * @experimental + */ + export interface Identifier { + type: "Identifier"; + range: [number, number]; + name: string; + optional: boolean; + typeAnnotation: TSTypeAnnotation | undefined; + } + + /** + * Private members inside of classes, must start with `#`. + * @category Linter + * @experimental + */ + export interface PrivateIdentifier { + type: "PrivateIdentifier"; + range: [number, number]; + name: string; + } + + /** + * Assign default values in parameters. + * @category Linter + * @experimental + */ + export interface AssignmentPattern { + type: "AssignmentPattern"; + range: [number, number]; + left: ArrayPattern | ObjectPattern | Identifier; + right: Expression; + } + + /** + * Destructure an array. + * @category Linter + * @experimental + */ + export interface ArrayPattern { + type: "ArrayPattern"; + range: [number, number]; + optional: boolean; + typeAnnotation: TSTypeAnnotation | undefined; + elements: Array< + | ArrayPattern + | AssignmentPattern + | Identifier + | MemberExpression + | ObjectPattern + | RestElement + | null + >; + } + + /** + * Destructure an object. + * @category Linter + * @experimental + */ + export interface ObjectPattern { + type: "ObjectPattern"; + range: [number, number]; + optional: boolean; + typeAnnotation: TSTypeAnnotation | undefined; + properties: Array; + } + + /** + * The rest of function parameters. + * @category Linter + * @experimental + */ + export interface RestElement { + type: "RestElement"; + range: [number, number]; + typeAnnotation: TSTypeAnnotation | undefined; + argument: + | ArrayPattern + | AssignmentPattern + | Identifier + | MemberExpression + | ObjectPattern + | RestElement; + } + + /** + * @category Linter + * @experimental + */ + export interface SpreadElement { + type: "SpreadElement"; + range: [number, number]; + argument: Expression; + } + + /** + * @category Linter + * @experimental + */ + export interface Property { + type: "Property"; + range: [number, number]; + shorthand: boolean; + computed: boolean; + method: boolean; + kind: "get" | "init" | "set"; + key: Expression | Identifier | NumberLiteral | StringLiteral; + value: + | AssignmentPattern + | ArrayPattern + | ObjectPattern + | Identifier + | Expression + | TSEmptyBodyFunctionExpression; + } + + /** + * Represents numbers that are too high or too low to be represented + * by the `number` type. + * + * ```ts + * const a = 9007199254740991n; + * ``` + * @category Linter + * @experimental + */ + export interface BigIntLiteral { + type: "Literal"; + range: [number, number]; + raw: string; + bigint: string; + value: bigint; + } + + /** + * Either `true` or `false` + * @category Linter + * @experimental + */ + export interface BooleanLiteral { + type: "Literal"; + range: [number, number]; + raw: "false" | "true"; + value: boolean; + } + + /** + * A number literal + * + * ```ts + * 1; + * 1.2; + * ``` + * @category Linter + * @experimental + */ + export interface NumberLiteral { + type: "Literal"; + range: [number, number]; + raw: string; + value: number; + } + + /** + * The `null` literal + * @category Linter + * @experimental + */ + export interface NullLiteral { + type: "Literal"; + range: [number, number]; + raw: "null"; + value: null; + } + + /** + * A string literal + * + * ```ts + * "foo"; + * 'foo "bar"'; + * ``` + * @category Linter + * @experimental + */ + export interface StringLiteral { + type: "Literal"; + range: [number, number]; + raw: string; + value: string; + } + + /** + * A regex literal: + * + * ```ts + * /foo(bar|baz)$/g + * ``` + * @category Linter + * @experimental + */ + export interface RegExpLiteral { + type: "Literal"; + range: [number, number]; + raw: string; + regex: { + flags: string; + pattern: string; + }; + value: RegExp | null; + } + + /** + * Union type of all Literals + * @category Linter + * @experimental + */ + export type Literal = + | BigIntLiteral + | BooleanLiteral + | NullLiteral + | NumberLiteral + | RegExpLiteral + | StringLiteral; + + /** + * User named identifier inside JSX. + * @category Linter + * @experimental + */ + export interface JSXIdentifier { + type: "JSXIdentifier"; + range: [number, number]; + name: string; + } + + /** + * Namespaced name in JSX + * @category Linter + * @experimental + */ + export interface JSXNamespacedName { + type: "JSXNamespacedName"; + range: [number, number]; + namespace: JSXIdentifier; + name: JSXIdentifier; + } + + /** + * Empty JSX expression. + * @category Linter + * @experimental + */ + export interface JSXEmptyExpression { + type: "JSXEmptyExpression"; + range: [number, number]; + } + + /** + * A JSX element. + * @category Linter + * @experimental + */ + export interface JSXElement { + type: "JSXElement"; + range: [number, number]; + openingElement: JSXOpeningElement; + closingElement: JSXClosingElement | null; + children: JSXChild[]; + } + + /** + * The opening tag of a JSXElement + * @category Linter + * @experimental + */ + export interface JSXOpeningElement { + type: "JSXOpeningElement"; + range: [number, number]; + selfClosing: boolean; + name: + | JSXIdentifier + | JSXMemberExpression + | JSXNamespacedName; + attributes: Array; + typeArguments: TSTypeParameterInstantiation | undefined; + } + + /** + * A JSX attribute + * @category Linter + * @experimental + */ + export interface JSXAttribute { + type: "JSXAttribute"; + range: [number, number]; + name: JSXIdentifier | JSXNamespacedName; + value: + | JSXElement + | JSXExpressionContainer + | Literal + | null; + } + + /** + * Spreads an object as JSX attributes. + * @category Linter + * @experimental + */ + export interface JSXSpreadAttribute { + type: "JSXSpreadAttribute"; + range: [number, number]; + argument: Expression; + } + + /** + * The closing tag of a JSXElement. Only used when the element + * is not self-closing. + * @category Linter + * @experimental + */ + export interface JSXClosingElement { + type: "JSXClosingElement"; + range: [number, number]; + name: + | JSXIdentifier + | JSXMemberExpression + | JSXNamespacedName; + } + + /** + * Usually a passthrough node to pass multiple sibling elements as + * the JSX syntax requires one root element. + * @category Linter + * @experimental + */ + export interface JSXFragment { + type: "JSXFragment"; + range: [number, number]; + openingFragment: JSXOpeningFragment; + closingFragment: JSXClosingFragment; + children: JSXChild[]; + } + + /** + * The opening tag of a JSXFragment. + * @category Linter + * @experimental + */ + export interface JSXOpeningFragment { + type: "JSXOpeningFragment"; + range: [number, number]; + } + + /** + * The closing tag of a JSXFragment. + * @category Linter + * @experimental + */ + export interface JSXClosingFragment { + type: "JSXClosingFragment"; + range: [number, number]; + } + + /** + * Inserts a normal JS expression into JSX. + * @category Linter + * @experimental + */ + export interface JSXExpressionContainer { + type: "JSXExpressionContainer"; + range: [number, number]; + expression: Expression | JSXEmptyExpression; + } + + /** + * Plain text in JSX. + * @category Linter + * @experimental + */ + export interface JSXText { + type: "JSXText"; + range: [number, number]; + raw: string; + value: string; + } + + /** + * JSX member expression. + * @category Linter + * @experimental + */ + export interface JSXMemberExpression { + type: "JSXMemberExpression"; + range: [number, number]; + object: + | JSXIdentifier + | JSXMemberExpression + | JSXNamespacedName; + property: JSXIdentifier; + } + + /** + * Union type of all possible child nodes in JSX + * @category Linter + * @experimental + */ + export type JSXChild = + | JSXElement + | JSXExpressionContainer + | JSXFragment + | JSXText; + + /** + * @category Linter + * @experimental + */ + export interface TSModuleDeclaration { + type: "TSModuleDeclaration"; + range: [number, number]; + declare: boolean; + kind: "global" | "module" | "namespace"; + id: Identifier | Literal | TSQualifiedName; + body: TSModuleBlock | undefined; + } + + /** + * Body of a `TSModuleDeclaration` + * @category Linter + * @experimental + */ + export interface TSModuleBlock { + type: "TSModuleBlock"; + range: [number, number]; + body: Array< + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ImportDeclaration + | Statement + | TSImportEqualsDeclaration + | TSNamespaceExportDeclaration + >; + } + + /** + * @category Linter + * @experimental + */ + export interface TSClassImplements { + type: "TSClassImplements"; + range: [number, number]; + expression: Expression; + typeArguments: TSTypeParameterInstantiation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSAbstractMethodDefinition { + type: "TSAbstractMethodDefinition"; + range: [number, number]; + computed: boolean; + optional: boolean; + override: boolean; + static: boolean; + accessibility: Accessibility | undefined; + kind: "method"; + key: Expression | Identifier | NumberLiteral | StringLiteral; + value: FunctionExpression | TSEmptyBodyFunctionExpression; + } + + /** + * @category Linter + * @experimental + */ + export interface TSAbstractPropertyDefinition { + type: "TSAbstractPropertyDefinition"; + range: [number, number]; + computed: boolean; + optional: boolean; + override: boolean; + static: boolean; + definite: boolean; + declare: boolean; + readonly: boolean; + accessibility: Accessibility | undefined; + decorators: Decorator[]; + key: + | Expression + | PrivateIdentifier + | Identifier + | NumberLiteral + | StringLiteral; + typeAnnotation: TSTypeAnnotation | undefined; + value: Expression | null; + } + + /** + * @category Linter + * @experimental + */ + export interface TSEmptyBodyFunctionExpression { + type: "TSEmptyBodyFunctionExpression"; + range: [number, number]; + declare: boolean; + expression: boolean; + async: boolean; + generator: boolean; + id: null; + body: null; + typeParameters: TSTypeParameterDeclaration | undefined; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSParameterProperty { + type: "TSParameterProperty"; + range: [number, number]; + override: boolean; + readonly: boolean; + static: boolean; + accessibility: Accessibility | undefined; + decorators: Decorator[]; + parameter: + | AssignmentPattern + | ArrayPattern + | ObjectPattern + | Identifier + | RestElement; + } + + /** + * @category Linter + * @experimental + */ + export interface TSCallSignatureDeclaration { + type: "TSCallSignatureDeclaration"; + range: [number, number]; + typeParameters: TSTypeParameterDeclaration | undefined; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSPropertySignature { + type: "TSPropertySignature"; + range: [number, number]; + computed: boolean; + optional: boolean; + readonly: boolean; + static: boolean; + key: + | PrivateIdentifier + | Expression + | Identifier + | NumberLiteral + | StringLiteral; + typeAnnotation: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSDeclareFunction { + type: "TSDeclareFunction"; + range: [number, number]; + async: boolean; + declare: boolean; + generator: boolean; + body: undefined; + id: Identifier | null; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + typeParameters: TSTypeParameterDeclaration | undefined; + } + + /** + * ```ts + * enum Foo { A, B }; + * ``` + * @category Linter + * @experimental + */ + export interface TSEnumDeclaration { + type: "TSEnumDeclaration"; + range: [number, number]; + declare: boolean; + const: boolean; + id: Identifier; + body: TSEnumBody; + } + + /** + * The body of a `TSEnumDeclaration` + * @category Linter + * @experimental + */ + export interface TSEnumBody { + type: "TSEnumBody"; + range: [number, number]; + members: TSEnumMember[]; + } + + /** + * A member of a `TSEnumDeclaration` + * @category Linter + * @experimental + */ + export interface TSEnumMember { + type: "TSEnumMember"; + range: [number, number]; + id: + | Identifier + | NumberLiteral + | StringLiteral; + initializer: Expression | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeAssertion { + type: "TSTypeAssertion"; + range: [number, number]; + expression: Expression; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeParameterInstantiation { + type: "TSTypeParameterInstantiation"; + range: [number, number]; + params: TypeNode[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration"; + range: [number, number]; + declare: boolean; + id: Identifier; + typeParameters: TSTypeParameterDeclaration | undefined; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSSatisfiesExpression { + type: "TSSatisfiesExpression"; + range: [number, number]; + expression: Expression; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSAsExpression { + type: "TSAsExpression"; + range: [number, number]; + expression: Expression; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSInstantiationExpression { + type: "TSInstantiationExpression"; + range: [number, number]; + expression: Expression; + typeArguments: TSTypeParameterInstantiation; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNonNullExpression { + type: "TSNonNullExpression"; + range: [number, number]; + expression: Expression; + } + + /** + * @category Linter + * @experimental + */ + export interface TSThisType { + type: "TSThisType"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSInterfaceDeclaration { + type: "TSInterfaceDeclaration"; + range: [number, number]; + declare: boolean; + id: Identifier; + extends: TSInterfaceHeritage[]; + typeParameters: TSTypeParameterDeclaration | undefined; + body: TSInterfaceBody; + } + + /** + * @category Linter + * @experimental + */ + export interface TSInterfaceBody { + type: "TSInterfaceBody"; + range: [number, number]; + body: Array< + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSIndexSignature + | TSMethodSignature + | TSPropertySignature + >; + } + + /** + * @category Linter + * @experimental + */ + export interface TSConstructSignatureDeclaration { + type: "TSConstructSignatureDeclaration"; + range: [number, number]; + typeParameters: TSTypeParameterDeclaration | undefined; + params: Parameter[]; + returnType: TSTypeAnnotation; + } + + /** + * @category Linter + * @experimental + */ + export interface TSMethodSignature { + type: "TSMethodSignature"; + range: [number, number]; + computed: boolean; + optional: boolean; + readonly: boolean; + static: boolean; + kind: "get" | "set" | "method"; + key: Expression | Identifier | NumberLiteral | StringLiteral; + returnType: TSTypeAnnotation | undefined; + params: Parameter[]; + typeParameters: TSTypeParameterDeclaration | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSInterfaceHeritage { + type: "TSInterfaceHeritage"; + range: [number, number]; + expression: Expression; + typeArguments: TSTypeParameterInstantiation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSIndexSignature { + type: "TSIndexSignature"; + range: [number, number]; + readonly: boolean; + static: boolean; + parameters: Parameter[]; + typeAnnotation: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSUnionType { + type: "TSUnionType"; + range: [number, number]; + types: TypeNode[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSIntersectionType { + type: "TSIntersectionType"; + range: [number, number]; + types: TypeNode[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSInferType { + type: "TSInferType"; + range: [number, number]; + typeParameter: TSTypeParameter; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeOperator { + type: "TSTypeOperator"; + range: [number, number]; + operator: "keyof" | "readonly" | "unique"; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSIndexedAccessType { + type: "TSIndexedAccessType"; + range: [number, number]; + indexType: TypeNode; + objectType: TypeNode; + } + + /** + * ```ts + * const a: any = null; + * ``` + * @category Linter + * @experimental + */ + export interface TSAnyKeyword { + type: "TSAnyKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSUnknownKeyword { + type: "TSUnknownKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNumberKeyword { + type: "TSNumberKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSObjectKeyword { + type: "TSObjectKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSBooleanKeyword { + type: "TSBooleanKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSBigIntKeyword { + type: "TSBigIntKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSStringKeyword { + type: "TSStringKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSSymbolKeyword { + type: "TSSymbolKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSVoidKeyword { + type: "TSVoidKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSUndefinedKeyword { + type: "TSUndefinedKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNullKeyword { + type: "TSNullKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNeverKeyword { + type: "TSNeverKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSIntrinsicKeyword { + type: "TSIntrinsicKeyword"; + range: [number, number]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSRestType { + type: "TSRestType"; + range: [number, number]; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSConditionalType { + type: "TSConditionalType"; + range: [number, number]; + checkType: TypeNode; + extendsType: TypeNode; + trueType: TypeNode; + falseType: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSMappedType { + type: "TSMappedType"; + range: [number, number]; + readonly: boolean; + optional: boolean; + nameType: TypeNode | null; + typeAnnotation: TypeNode | undefined; + constraint: TypeNode; + key: Identifier; + } + + /** + * @category Linter + * @experimental + */ + export interface TSLiteralType { + type: "TSLiteralType"; + range: [number, number]; + literal: Literal | TemplateLiteral | UnaryExpression | UpdateExpression; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTemplateLiteralType { + type: "TSTemplateLiteralType"; + range: [number, number]; + quasis: TemplateElement[]; + types: TypeNode[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeLiteral { + type: "TSTypeLiteral"; + range: [number, number]; + members: Array< + | TSCallSignatureDeclaration + | TSConstructSignatureDeclaration + | TSIndexSignature + | TSMethodSignature + | TSPropertySignature + >; + } + + /** + * @category Linter + * @experimental + */ + export interface TSOptionalType { + type: "TSOptionalType"; + range: [number, number]; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeAnnotation { + type: "TSTypeAnnotation"; + range: [number, number]; + typeAnnotation: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSArrayType { + type: "TSArrayType"; + range: [number, number]; + elementType: TypeNode; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeQuery { + type: "TSTypeQuery"; + range: [number, number]; + exprName: Identifier | ThisExpression | TSQualifiedName | TSImportType; + typeArguments: TSTypeParameterInstantiation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeReference { + type: "TSTypeReference"; + range: [number, number]; + typeName: Identifier | ThisExpression | TSQualifiedName; + typeArguments: TSTypeParameterInstantiation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypePredicate { + type: "TSTypePredicate"; + range: [number, number]; + asserts: boolean; + parameterName: Identifier | TSThisType; + typeAnnotation: TSTypeAnnotation | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTupleType { + type: "TSTupleType"; + range: [number, number]; + elementTypes: TypeNode[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSNamedTupleMember { + type: "TSNamedTupleMember"; + range: [number, number]; + label: Identifier; + elementType: TypeNode; + optional: boolean; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration"; + range: [number, number]; + params: TSTypeParameter[]; + } + + /** + * @category Linter + * @experimental + */ + export interface TSTypeParameter { + type: "TSTypeParameter"; + range: [number, number]; + in: boolean; + out: boolean; + const: boolean; + name: Identifier; + constraint: TypeNode | null; + default: TypeNode | null; + } + + /** + * @category Linter + * @experimental + */ + export interface TSImportType { + type: "TSImportType"; + range: [number, number]; + argument: TypeNode; + qualifier: Identifier | ThisExpression | TSQualifiedName | null; + typeArguments: TSTypeParameterInstantiation | null; + } + + /** + * @category Linter + * @experimental + */ + export interface TSExportAssignment { + type: "TSExportAssignment"; + range: [number, number]; + expression: Expression; + } + + /** + * @category Linter + * @experimental + */ + export interface TSFunctionType { + type: "TSFunctionType"; + range: [number, number]; + params: Parameter[]; + returnType: TSTypeAnnotation | undefined; + typeParameters: TSTypeParameterDeclaration | undefined; + } + + /** + * @category Linter + * @experimental + */ + export interface TSQualifiedName { + type: "TSQualifiedName"; + range: [number, number]; + left: Identifier | ThisExpression | TSQualifiedName; + right: Identifier; + } + + /** + * Union type of all possible statement nodes + * @category Linter + * @experimental + */ + export type Statement = + | BlockStatement + | BreakStatement + | ClassDeclaration + | ContinueStatement + | DebuggerStatement + | DoWhileStatement + | ExportAllDeclaration + | ExportDefaultDeclaration + | ExportNamedDeclaration + | ExpressionStatement + | ForInStatement + | ForOfStatement + | ForStatement + | FunctionDeclaration + | IfStatement + | ImportDeclaration + | LabeledStatement + | ReturnStatement + | SwitchStatement + | ThrowStatement + | TryStatement + | TSDeclareFunction + | TSEnumDeclaration + | TSExportAssignment + | TSImportEqualsDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSNamespaceExportDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration + | WhileStatement + | WithStatement; + + /** + * Union type of all possible expression nodes + * @category Linter + * @experimental + */ + export type Expression = + | ArrayExpression + | ArrayPattern + | ArrowFunctionExpression + | AssignmentExpression + | AwaitExpression + | BinaryExpression + | CallExpression + | ChainExpression + | ClassExpression + | ConditionalExpression + | FunctionExpression + | Identifier + | ImportExpression + | JSXElement + | JSXFragment + | Literal + | TemplateLiteral + | LogicalExpression + | MemberExpression + | MetaProperty + | NewExpression + | ObjectExpression + | ObjectPattern + | SequenceExpression + | Super + | TaggedTemplateExpression + | TemplateLiteral + | ThisExpression + | TSAsExpression + | TSInstantiationExpression + | TSNonNullExpression + | TSSatisfiesExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression + | YieldExpression; + + /** + * Union type of all possible type nodes in TypeScript + * @category Linter + * @experimental + */ + export type TypeNode = + | TSAnyKeyword + | TSArrayType + | TSBigIntKeyword + | TSBooleanKeyword + | TSConditionalType + | TSFunctionType + | TSImportType + | TSIndexedAccessType + | TSInferType + | TSIntersectionType + | TSIntrinsicKeyword + | TSLiteralType + | TSMappedType + | TSNamedTupleMember + | TSNeverKeyword + | TSNullKeyword + | TSNumberKeyword + | TSObjectKeyword + | TSOptionalType + | TSQualifiedName + | TSRestType + | TSStringKeyword + | TSSymbolKeyword + | TSTemplateLiteralType + | TSThisType + | TSTupleType + | TSTypeLiteral + | TSTypeOperator + | TSTypePredicate + | TSTypeQuery + | TSTypeReference + | TSUndefinedKeyword + | TSUnionType + | TSUnknownKeyword + | TSVoidKeyword; } export {}; // only export exports From dd1ee5821bfb8856a543be46dc537108b03dce23 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Thu, 6 Feb 2025 21:45:56 +0100 Subject: [PATCH 2/6] feat(unstable): align lint ast with TSEStree (#27996) This PR fixes deviations in our AST format compared to TSEStree. They are mostly a leftover for when I first started working on it and based it off of babel instead. One of the key changes why the changeset is a bit bigger is that TSEStree uses `undefined` instead of `null` as the empty value for type nodes. This is likely influenced by `tsc` which use `undefined` everywhere. The rest of the nodes use `null` though. It's a little weird, but for now it might be better to align. (extracted from https://github.com/denoland/deno/pull/27977) --- cli/tools/lint/ast_buffer/buffer.rs | 16 + cli/tools/lint/ast_buffer/swc.rs | 260 +- cli/tools/lint/ast_buffer/ts_estree.rs | 314 ++- .../__snapshots__/lint_plugin_test.ts.snap | 2418 +++++++++++------ tests/unit/lint_plugin_test.ts | 114 +- 5 files changed, 2158 insertions(+), 964 deletions(-) diff --git a/cli/tools/lint/ast_buffer/buffer.rs b/cli/tools/lint/ast_buffer/buffer.rs index b3e4926f241918..22afba4cdca051 100644 --- a/cli/tools/lint/ast_buffer/buffer.rs +++ b/cli/tools/lint/ast_buffer/buffer.rs @@ -485,6 +485,22 @@ impl SerializeCtx { }; } + /// Helper for writing optional node offsets with undefined as empty value + pub fn write_maybe_undef_ref

( + &mut self, + prop: P, + parent: &PendingRef, + value: Option, + ) where + P: Into + Display + Clone, + { + if let Some(v) = value { + self.write_ref(prop, parent, v); + } else { + self.write_undefined(prop); + }; + } + /// Write a vec of node offsets into the property. The necessary space /// has been reserved earlier. pub fn write_ref_vec

( diff --git a/cli/tools/lint/ast_buffer/swc.rs b/cli/tools/lint/ast_buffer/swc.rs index 385035d023ea1c..ef6fac90944893 100644 --- a/cli/tools/lint/ast_buffer/swc.rs +++ b/cli/tools/lint/ast_buffer/swc.rs @@ -80,6 +80,7 @@ use deno_ast::swc::common::SyntaxContext; use deno_ast::view::Accessibility; use deno_ast::view::AssignOp; use deno_ast::view::BinaryOp; +use deno_ast::view::MetaPropKind; use deno_ast::view::MethodKind; use deno_ast::view::TsKeywordTypeKind; use deno_ast::view::TsTypeOperatorOp; @@ -91,8 +92,11 @@ use deno_ast::ParsedSource; use super::buffer::AstBufSerializer; use super::buffer::NodeRef; use super::ts_estree::AstNode; +use super::ts_estree::MethodKind as TsEstreeMethodKind; +use super::ts_estree::PropertyKind; use super::ts_estree::TsEsTreeBuilder; use super::ts_estree::TsKeywordKind; +use super::ts_estree::TsModuleKind; use crate::util::text_encoding::Utf16Map; pub fn serialize_swc_to_buffer( @@ -175,8 +179,26 @@ fn serialize_module_decl( ctx.write_import_decl(&node.span, node.type_only, src, specifiers, attrs) } ModuleDecl::ExportDecl(node) => { + let is_type_only = match &node.decl { + Decl::Class(_) => false, + Decl::Fn(_) => false, + Decl::Var(_) => false, + Decl::Using(_) => false, + Decl::TsInterface(_) => true, + Decl::TsTypeAlias(_) => true, + Decl::TsEnum(_) => true, + Decl::TsModule(_) => true, + }; let decl = serialize_decl(ctx, &node.decl); - ctx.write_export_decl(&node.span, decl) + + ctx.write_export_named_decl( + &node.span, + is_type_only, + vec![], + None, + vec![], + Some(decl), + ) } ModuleDecl::ExportNamed(node) => { let attrs = serialize_import_attrs(ctx, &node.with); @@ -224,7 +246,14 @@ fn serialize_module_decl( }) .collect::>(); - ctx.write_export_named_decl(&node.span, specifiers, source, attrs) + ctx.write_export_named_decl( + &node.span, + node.type_only, + specifiers, + source, + attrs, + None, + ) } } ModuleDecl::ExportDefaultDecl(node) => { @@ -293,17 +322,30 @@ fn serialize_module_decl( .as_ref() .map(|block| serialize_stmt(ctx, &Stmt::Block(block.clone()))); - let decl = ctx.write_fn_decl( - &fn_obj.span, - false, - fn_obj.is_async, - fn_obj.is_generator, - ident, - type_params, - return_type, - body, - params, - ); + let decl = if let Some(body) = body { + ctx.write_fn_decl( + &fn_obj.span, + false, + fn_obj.is_async, + fn_obj.is_generator, + ident, + type_params, + return_type, + body, + params, + ) + } else { + ctx.write_ts_decl_fn( + &fn_obj.span, + false, + fn_obj.is_async, + fn_obj.is_generator, + ident, + type_params, + return_type, + params, + ) + }; (false, decl) } @@ -797,7 +839,7 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { let options = node .args .get(1) - .map_or(NodeRef(0), |arg| serialize_expr_or_spread(ctx, arg)); + .map(|arg| serialize_expr_or_spread(ctx, arg)); ctx.write_import_expr(&node.span, source, options) } else { @@ -919,12 +961,21 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { .as_ref() .map(|ident| serialize_ident(ctx, ident, None)); + let type_params = + maybe_serialize_ts_type_param_decl(ctx, &node.class.type_params); + let super_class = node .class .super_class .as_ref() .map(|expr| serialize_expr(ctx, expr.as_ref())); + let super_type_args = node + .class + .super_type_params + .as_ref() + .map(|param| serialize_ts_param_inst(ctx, param.as_ref())); + let implements = node .class .implements @@ -947,6 +998,8 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { node.class.is_abstract, ident, super_class, + super_type_args, + type_params, implements, body, ) @@ -960,8 +1013,17 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { ctx.write_yield_expr(&node.span, node.delegate, arg) } Expr::MetaProp(node) => { - let prop = ctx.write_identifier(&node.span, "meta", false, None); - ctx.write_meta_prop(&node.span, prop) + let (meta, prop) = match node.kind { + MetaPropKind::NewTarget => ( + ctx.write_identifier(&node.span, "new", false, None), + ctx.write_identifier(&node.span, "target", false, None), + ), + MetaPropKind::ImportMeta => ( + ctx.write_identifier(&node.span, "import", false, None), + ctx.write_identifier(&node.span, "meta", false, None), + ), + }; + ctx.write_meta_prop(&node.span, meta, prop) } Expr::Await(node) => { let arg = serialize_expr(ctx, node.arg.as_ref()); @@ -1001,9 +1063,10 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { ctx.write_ts_as_expr(&node.span, expr, type_ann) } - Expr::TsInstantiation(_) => { - // Invalid syntax - unreachable!() + Expr::TsInstantiation(node) => { + let expr = serialize_expr(ctx, &node.expr); + let type_args = serialize_ts_param_inst(ctx, node.type_args.as_ref()); + ctx.write_ts_inst_expr(&node.span, expr, type_args) } Expr::TsSatisfies(node) => { let expr = serialize_expr(ctx, node.expr.as_ref()); @@ -1057,7 +1120,7 @@ fn serialize_prop_or_spread( let mut shorthand = false; let mut computed = false; let mut method = false; - let mut kind = "init"; + let mut kind = PropertyKind::Init; let (key, value) = match prop.as_ref() { Prop::Shorthand(ident) => { @@ -1086,7 +1149,7 @@ fn serialize_prop_or_spread( (left, child_pos) } Prop::Getter(getter_prop) => { - kind = "get"; + kind = PropertyKind::Get; let key = serialize_prop_name(ctx, &getter_prop.key); @@ -1111,7 +1174,7 @@ fn serialize_prop_or_spread( (key, value) } Prop::Setter(setter_prop) => { - kind = "set"; + kind = PropertyKind::Set; let key_id = serialize_prop_name(ctx, &setter_prop.key); @@ -1280,17 +1343,30 @@ fn serialize_decl(ctx: &mut TsEsTreeBuilder, decl: &Decl) -> NodeRef { .map(|param| serialize_pat(ctx, ¶m.pat)) .collect::>(); - ctx.write_fn_decl( - &node.function.span, - node.declare, - node.function.is_async, - node.function.is_generator, - Some(ident_id), - type_param_id, - return_type, - body, - params, - ) + if let Some(body) = body { + ctx.write_fn_decl( + &node.function.span, + node.declare, + node.function.is_async, + node.function.is_generator, + Some(ident_id), + type_param_id, + return_type, + body, + params, + ) + } else { + ctx.write_ts_decl_fn( + &node.function.span, + node.declare, + node.function.is_async, + node.function.is_generator, + Some(ident_id), + type_param_id, + return_type, + params, + ) + } } Decl::Var(node) => { let children = node @@ -1303,7 +1379,7 @@ fn serialize_decl(ctx: &mut TsEsTreeBuilder, decl: &Decl) -> NodeRef { .as_ref() .map(|init| serialize_expr(ctx, init.as_ref())); - ctx.write_var_declarator(&decl.span, ident, init) + ctx.write_var_declarator(&decl.span, ident, init, decl.definite) }) .collect::>(); @@ -1332,7 +1408,7 @@ fn serialize_decl(ctx: &mut TsEsTreeBuilder, decl: &Decl) -> NodeRef { .as_ref() .map(|init| serialize_expr(ctx, init.as_ref())); - ctx.write_var_declarator(&decl.span, ident, init) + ctx.write_var_declarator(&decl.span, ident, init, decl.definite) }) .collect::>(); @@ -1366,7 +1442,7 @@ fn serialize_decl(ctx: &mut TsEsTreeBuilder, decl: &Decl) -> NodeRef { let body_pos = ctx.write_ts_interface_body(&node.body.span, body_elem_ids); - ctx.write_ts_interface( + ctx.write_ts_interface_decl( &node.span, node.declare, ident_id, @@ -1428,7 +1504,11 @@ fn serialize_decl(ctx: &mut TsEsTreeBuilder, decl: &Decl) -> NodeRef { ctx.write_ts_module_decl( &node.span, node.declare, - node.global, + if node.global { + TsModuleKind::Global + } else { + TsModuleKind::Module + }, ident, body, ) @@ -1460,7 +1540,7 @@ fn serialize_ts_namespace_body( ctx.write_ts_module_decl( &node.span, node.declare, - node.global, + TsModuleKind::Namespace, ident, Some(body), ) @@ -1562,7 +1642,13 @@ fn serialize_ts_index_sig( .collect::>(); let type_ann = maybe_serialize_ts_type_ann(ctx, &node.type_ann); - ctx.write_ts_index_sig(&node.span, node.readonly, params, type_ann) + ctx.write_ts_index_sig( + &node.span, + node.is_static, + node.readonly, + params, + type_ann, + ) } fn accessibility_to_str(accessibility: &Accessibility) -> String { @@ -1785,7 +1871,7 @@ fn serialize_pat(ctx: &mut TsEsTreeBuilder, pat: &Pat) -> NodeRef { false, computed, false, - "init", + PropertyKind::Init, key, value, ) @@ -1803,7 +1889,7 @@ fn serialize_pat(ctx: &mut TsEsTreeBuilder, pat: &Pat) -> NodeRef { false, false, false, - "init", + PropertyKind::Init, ident, value, ) @@ -1995,7 +2081,7 @@ fn serialize_class_member( node.is_optional, false, false, - "constructor", + TsEstreeMethodKind::Constructor, a11y, key, value, @@ -2045,19 +2131,41 @@ fn serialize_class_member( .map(|deco| serialize_decorator(ctx, deco)) .collect::>(); - Some(ctx.write_class_prop( - &node.span, - node.declare, - false, - node.is_optional, - node.is_override, - node.readonly, - node.is_static, - a11y, - decorators, - key, - value, - )) + let type_ann = maybe_serialize_ts_type_ann(ctx, &node.type_ann); + + let out = if node.is_abstract { + ctx.write_ts_abstract_prop_def( + &node.span, + false, + node.is_optional, + node.is_override, + node.is_static, + node.definite, + node.readonly, + node.declare, + a11y, + decorators, + key, + type_ann, + ) + } else { + ctx.write_class_prop( + &node.span, + node.declare, + false, + node.is_optional, + node.is_override, + node.readonly, + node.is_static, + a11y, + decorators, + key, + value, + type_ann, + ) + }; + + Some(out) } ClassMember::PrivateProp(node) => { let a11y = node.accessibility.as_ref().map(accessibility_to_str); @@ -2072,6 +2180,8 @@ fn serialize_class_member( let value = node.value.as_ref().map(|expr| serialize_expr(ctx, expr)); + let type_ann = maybe_serialize_ts_type_ann(ctx, &node.type_ann); + Some(ctx.write_class_prop( &node.span, false, @@ -2084,6 +2194,7 @@ fn serialize_class_member( decorators, key, value, + type_ann, )) } ClassMember::TsIndexSignature(node) => { @@ -2140,9 +2251,9 @@ fn serialize_class_method( function: &Function, ) -> NodeRef { let kind = match method_kind { - MethodKind::Method => "method", - MethodKind::Getter => "getter", - MethodKind::Setter => "setter", + MethodKind::Method => TsEstreeMethodKind::Method, + MethodKind::Getter => TsEstreeMethodKind::Get, + MethodKind::Setter => TsEstreeMethodKind::Set, }; let type_params = @@ -2178,7 +2289,6 @@ fn serialize_class_method( false, function.is_async, function.is_generator, - None, type_params, params, return_type, @@ -2283,7 +2393,18 @@ fn serialize_ts_type(ctx: &mut TsEsTreeBuilder, node: &TsType) -> NodeRef { .map(|param| serialize_ts_fn_param(ctx, param)) .collect::>(); - ctx.write_ts_fn_type(&node.span, param_ids) + let type_params = node + .type_params + .as_ref() + .map(|param| serialize_ts_type_param_decl(ctx, param)); + let return_type = serialize_ts_type_ann(ctx, node.type_ann.as_ref()); + + ctx.write_ts_fn_type( + &node.span, + type_params, + param_ids, + Some(return_type), + ) } TsFnOrConstructorType::TsConstructorType(node) => { // interface Foo { new(arg1: any): any } @@ -2349,10 +2470,17 @@ fn serialize_ts_type(ctx: &mut TsEsTreeBuilder, node: &TsType) -> NodeRef { .iter() .map(|elem| { if let Some(label) = &elem.label { + let optional = match label { + Pat::Ident(binding_ident) => binding_ident.optional, + Pat::Array(array_pat) => array_pat.optional, + Pat::Object(object_pat) => object_pat.optional, + _ => false, + }; let label = serialize_pat(ctx, label); let type_id = serialize_ts_type(ctx, elem.ty.as_ref()); - ctx.write_ts_named_tuple_member(&elem.span, label, type_id) + ctx + .write_ts_named_tuple_member(&elem.span, label, type_id, optional) } else { serialize_ts_type(ctx, elem.ty.as_ref()) } @@ -2425,7 +2553,12 @@ fn serialize_ts_type(ctx: &mut TsEsTreeBuilder, node: &TsType) -> NodeRef { TsType::TsMappedType(node) => { let name = maybe_serialize_ts_type(ctx, &node.name_type); let type_ann = maybe_serialize_ts_type(ctx, &node.type_ann); - let type_param = serialize_ts_type_param(ctx, &node.type_param); + let key = serialize_ident(ctx, &node.type_param.name, None); + let constraint = node + .type_param + .constraint + .as_ref() + .map_or(NodeRef(0), |node| serialize_ts_type(ctx, node)); ctx.write_ts_mapped_type( &node.span, @@ -2433,7 +2566,8 @@ fn serialize_ts_type(ctx: &mut TsEsTreeBuilder, node: &TsType) -> NodeRef { node.optional, name, type_ann, - type_param, + key, + constraint, ) } TsType::TsLitType(node) => serialize_ts_lit_type(ctx, node), diff --git a/cli/tools/lint/ast_buffer/ts_estree.rs b/cli/tools/lint/ast_buffer/ts_estree.rs index f5e89a2bede37d..ffbfd9fa36c804 100644 --- a/cli/tools/lint/ast_buffer/ts_estree.rs +++ b/cli/tools/lint/ast_buffer/ts_estree.rs @@ -173,12 +173,15 @@ pub enum AstNode { TSArrayType, TSClassImplements, TSAbstractMethodDefinition, + TSAbstractPropertyDefinition, TSEmptyBodyFunctionExpression, TSParameterProperty, TSConstructSignatureDeclaration, TSQualifiedName, TSOptionalType, TSTemplateLiteralType, + TSDeclareFunction, + TSInstantiationExpression, TSAnyKeyword, TSBigIntKeyword, @@ -582,12 +585,6 @@ impl TsEsTreeBuilder { self.ctx.commit_node(id) } - pub fn write_export_decl(&mut self, span: &Span, decl: NodeRef) -> NodeRef { - let id = self.ctx.append_node(AstNode::ExportNamedDeclaration, span); - self.ctx.write_ref(AstProp::Declaration, &id, decl); - self.ctx.commit_node(id) - } - pub fn write_export_all_decl( &mut self, span: &Span, @@ -626,14 +623,21 @@ impl TsEsTreeBuilder { pub fn write_export_named_decl( &mut self, span: &Span, + is_type_only: bool, specifiers: Vec, source: Option, attributes: Vec, + declaration: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::ExportNamedDeclaration, span); + let value = if is_type_only { "type" } else { "value" }; + self.ctx.write_str(AstProp::ExportKind, value); self.ctx.write_ref_vec(AstProp::Specifiers, &id, specifiers); self.ctx.write_maybe_ref(AstProp::Source, &id, source); + self + .ctx + .write_maybe_ref(AstProp::Declaration, &id, declaration); self.ctx.write_ref_vec(AstProp::Attributes, &id, attributes); self.ctx.commit_node(id) @@ -721,11 +725,43 @@ impl TsEsTreeBuilder { span: &Span, ident: NodeRef, init: Option, + definite: bool, ) -> NodeRef { let id = self.ctx.append_node(AstNode::VariableDeclarator, span); self.ctx.write_ref(AstProp::Id, &id, ident); self.ctx.write_maybe_ref(AstProp::Init, &id, init); + self.ctx.write_bool(AstProp::Definite, definite); + + self.ctx.commit_node(id) + } + + #[allow(clippy::too_many_arguments)] + pub fn write_ts_decl_fn( + &mut self, + span: &Span, + is_declare: bool, + is_async: bool, + is_generator: bool, + ident: Option, + type_param: Option, + return_type: Option, + params: Vec, + ) -> NodeRef { + let id = self.ctx.append_node(AstNode::TSDeclareFunction, span); + + self.ctx.write_bool(AstProp::Declare, is_declare); + self.ctx.write_bool(AstProp::Async, is_async); + self.ctx.write_bool(AstProp::Generator, is_generator); + self.ctx.write_maybe_ref(AstProp::Id, &id, ident); + self + .ctx + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_param); + self + .ctx + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); + self.ctx.write_undefined(AstProp::Body); + self.ctx.write_ref_vec(AstProp::Params, &id, params); self.ctx.commit_node(id) } @@ -742,7 +778,7 @@ impl TsEsTreeBuilder { ident: Option, type_param: Option, return_type: Option, - body: Option, + body: NodeRef, params: Vec, ) -> NodeRef { let id = self.ctx.append_node(AstNode::FunctionDeclaration, span); @@ -753,11 +789,11 @@ impl TsEsTreeBuilder { self.ctx.write_maybe_ref(AstProp::Id, &id, ident); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_param); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_param); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); - self.ctx.write_maybe_ref(AstProp::Body, &id, body); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); + self.ctx.write_ref(AstProp::Body, &id, body); self.ctx.write_ref_vec(AstProp::Params, &id, params); self.ctx.commit_node(id) @@ -803,6 +839,8 @@ impl TsEsTreeBuilder { is_abstract: bool, ident: Option, super_class: Option, + super_type_args: Option, + type_params: Option, implements: Vec, body: NodeRef, ) -> NodeRef { @@ -813,6 +851,14 @@ impl TsEsTreeBuilder { self .ctx .write_maybe_ref(AstProp::SuperClass, &id, super_class); + self.ctx.write_maybe_undef_ref( + AstProp::SuperTypeArguments, + &id, + super_type_args, + ); + self + .ctx + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.write_ref_vec(AstProp::Implements, &id, implements); self.ctx.write_ref(AstProp::Body, &id, body); @@ -880,6 +926,7 @@ impl TsEsTreeBuilder { decorators: Vec, key: NodeRef, value: Option, + type_ann: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::PropertyDefinition, span); @@ -895,6 +942,9 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Key, &id, key); self.ctx.write_maybe_ref(AstProp::Value, &id, value); + self + .ctx + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) } @@ -908,7 +958,7 @@ impl TsEsTreeBuilder { is_optional: bool, is_override: bool, is_static: bool, - kind: &str, + kind: MethodKind, accessibility: Option, key: NodeRef, value: NodeRef, @@ -920,10 +970,17 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Optional, is_optional); self.ctx.write_bool(AstProp::Override, is_override); self.ctx.write_bool(AstProp::Static, is_static); - self.ctx.write_str(AstProp::Kind, kind); + let kind_str = match kind { + MethodKind::Constructor => "constructor", + MethodKind::Get => "get", + MethodKind::Method => "method", + MethodKind::Set => "set", + }; + self.ctx.write_str(AstProp::Kind, kind_str); self.write_accessibility(accessibility); self.ctx.write_ref(AstProp::Key, &id, key); self.ctx.write_ref(AstProp::Value, &id, value); + self.ctx.write_ref_vec(AstProp::Decorators, &id, vec![]); self.ctx.commit_node(id) } @@ -1238,11 +1295,11 @@ impl TsEsTreeBuilder { self.ctx.write_maybe_ref(AstProp::Id, &id, ident); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_params); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.write_ref_vec(AstProp::Params, &id, params); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); self.ctx.write_maybe_ref(AstProp::Body, &id, body); self.ctx.commit_node(id) @@ -1265,11 +1322,11 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Generator, is_generator); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_params); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.write_ref_vec(AstProp::Params, &id, params); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); self.ctx.write_ref(AstProp::Body, &id, body); self.ctx.commit_node(id) @@ -1311,7 +1368,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Callee, &id, callee); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_args); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_args); self.ctx.write_ref_vec(AstProp::Arguments, &id, args); self.ctx.commit_node(id) @@ -1321,12 +1378,12 @@ impl TsEsTreeBuilder { &mut self, span: &Span, source: NodeRef, - options: NodeRef, + options: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::ImportExpression, span); self.ctx.write_ref(AstProp::Source, &id, source); - self.ctx.write_ref(AstProp::Options, &id, options); + self.ctx.write_maybe_ref(AstProp::Options, &id, options); self.ctx.commit_node(id) } @@ -1477,7 +1534,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Tag, &id, tag); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_args); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_args); self.ctx.write_ref(AstProp::Quasi, &id, quasi); self.ctx.commit_node(id) @@ -1503,8 +1560,14 @@ impl TsEsTreeBuilder { self.ctx.commit_node(id) } - pub fn write_meta_prop(&mut self, span: &Span, prop: NodeRef) -> NodeRef { + pub fn write_meta_prop( + &mut self, + span: &Span, + meta: NodeRef, + prop: NodeRef, + ) -> NodeRef { let id = self.ctx.append_node(AstNode::MetaProperty, span); + self.ctx.write_ref(AstProp::Meta, &id, meta); self.ctx.write_ref(AstProp::Property, &id, prop); self.ctx.commit_node(id) } @@ -1520,9 +1583,11 @@ impl TsEsTreeBuilder { self.ctx.write_str(AstProp::Name, name); self.ctx.write_bool(AstProp::Optional, optional); - self - .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_annotation); + self.ctx.write_maybe_undef_ref( + AstProp::TypeAnnotation, + &id, + type_annotation, + ); self.ctx.commit_node(id) } @@ -1563,7 +1628,7 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Optional, optional); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.write_ref_vec(AstProp::Elements, &id, elems); self.ctx.commit_node(id) @@ -1581,7 +1646,7 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Optional, optional); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.write_ref_vec(AstProp::Properties, &id, props); self.ctx.commit_node(id) @@ -1597,7 +1662,7 @@ impl TsEsTreeBuilder { self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.write_ref(AstProp::Argument, &id, arg); self.ctx.commit_node(id) @@ -1616,7 +1681,7 @@ impl TsEsTreeBuilder { shorthand: bool, computed: bool, method: bool, - kind: &str, + kind: PropertyKind, key: NodeRef, value: NodeRef, ) -> NodeRef { @@ -1625,7 +1690,12 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Shorthand, shorthand); self.ctx.write_bool(AstProp::Computed, computed); self.ctx.write_bool(AstProp::Method, method); - self.ctx.write_str(AstProp::Kind, kind); + let kind_str = match kind { + PropertyKind::Get => "get", + PropertyKind::Init => "init", + PropertyKind::Set => "set", + }; + self.ctx.write_str(AstProp::Kind, kind_str); self.ctx.write_ref(AstProp::Key, &id, key); self.ctx.write_ref(AstProp::Value, &id, value); @@ -1773,7 +1843,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref_vec(AstProp::Attributes, &id, attrs); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_args); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_args); self.ctx.commit_node(id) } @@ -1880,16 +1950,21 @@ impl TsEsTreeBuilder { &mut self, span: &Span, is_declare: bool, - is_global: bool, + kind: TsModuleKind, ident: NodeRef, body: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::TSModuleDeclaration, span); self.ctx.write_bool(AstProp::Declare, is_declare); - self.ctx.write_bool(AstProp::Global, is_global); + let kind_str = match kind { + TsModuleKind::Global => "global", + TsModuleKind::Namespace => "namespace", + TsModuleKind::Module => "module", + }; + self.ctx.write_str(AstProp::Kind, kind_str); self.ctx.write_ref(AstProp::Id, &id, ident); - self.ctx.write_maybe_ref(AstProp::Body, &id, body); + self.ctx.write_maybe_undef_ref(AstProp::Body, &id, body); self.ctx.commit_node(id) } @@ -1914,7 +1989,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Expression, &id, expr); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_args); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_args); self.ctx.commit_node(id) } @@ -1944,7 +2019,47 @@ impl TsEsTreeBuilder { self.ctx.write_str(AstProp::Kind, "method"); self.ctx.write_ref(AstProp::Key, &id, key); - self.ctx.write_ref(AstProp::Key, &id, value); + self.ctx.write_ref(AstProp::Value, &id, value); + + self.ctx.commit_node(id) + } + + #[allow(clippy::too_many_arguments)] + pub fn write_ts_abstract_prop_def( + &mut self, + span: &Span, + is_computed: bool, + is_optional: bool, + is_override: bool, + is_static: bool, + is_definite: bool, + is_readonly: bool, + is_declare: bool, + accessibility: Option, + decorators: Vec, + key: NodeRef, + type_ann: Option, + ) -> NodeRef { + let id = self + .ctx + .append_node(AstNode::TSAbstractPropertyDefinition, span); + + self.ctx.write_bool(AstProp::Computed, is_computed); + self.ctx.write_bool(AstProp::Optional, is_optional); + self.ctx.write_bool(AstProp::Override, is_override); + self.ctx.write_bool(AstProp::Static, is_static); + self.ctx.write_bool(AstProp::Definite, is_definite); + self.ctx.write_bool(AstProp::Declare, is_declare); + self.ctx.write_bool(AstProp::Readonly, is_readonly); + + self.write_accessibility(accessibility); + self.ctx.write_ref_vec(AstProp::Decorators, &id, decorators); + + self.ctx.write_ref(AstProp::Key, &id, key); + self.ctx.write_null(AstProp::Value); + self + .ctx + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) } @@ -1957,7 +2072,6 @@ impl TsEsTreeBuilder { is_expression: bool, is_async: bool, is_generator: bool, - ident: Option, type_params: Option, params: Vec, return_type: Option, @@ -1970,14 +2084,15 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Expression, is_expression); self.ctx.write_bool(AstProp::Async, is_async); self.ctx.write_bool(AstProp::Generator, is_generator); - self.ctx.write_maybe_ref(AstProp::Id, &id, ident); + self.ctx.write_null(AstProp::Id); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_params); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.write_ref_vec(AstProp::Params, &id, params); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); + self.ctx.write_null(AstProp::Body); self.ctx.commit_node(id) } @@ -2016,11 +2131,11 @@ impl TsEsTreeBuilder { self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_ann); self.ctx.write_ref_vec(AstProp::Params, &id, params); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); self.ctx.commit_node(id) } @@ -2045,7 +2160,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Key, &id, key); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) } @@ -2087,7 +2202,9 @@ impl TsEsTreeBuilder { let id = self.ctx.append_node(AstNode::TSEnumMember, span); self.ctx.write_ref(AstProp::Id, &id, ident); - self.ctx.write_maybe_ref(AstProp::Initializer, &id, init); + self + .ctx + .write_maybe_undef_ref(AstProp::Initializer, &id, init); self.ctx.commit_node(id) } @@ -2134,7 +2251,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Id, &id, ident); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_param); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_param); self.ctx.write_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) @@ -2154,6 +2271,22 @@ impl TsEsTreeBuilder { self.ctx.commit_node(id) } + pub fn write_ts_inst_expr( + &mut self, + span: &Span, + expr: NodeRef, + type_arg: NodeRef, + ) -> NodeRef { + let id = self + .ctx + .append_node(AstNode::TSInstantiationExpression, span); + + self.ctx.write_ref(AstProp::Expression, &id, expr); + self.ctx.write_ref(AstProp::TypeArguments, &id, type_arg); + + self.ctx.commit_node(id) + } + pub fn write_ts_as_expr( &mut self, span: &Span, @@ -2179,28 +2312,6 @@ impl TsEsTreeBuilder { self.ctx.commit_node(id) } - pub fn write_ts_interface( - &mut self, - span: &Span, - declare: bool, - ident: NodeRef, - type_param: Option, - extends: Vec, - body: NodeRef, - ) -> NodeRef { - let id = self.ctx.append_node(AstNode::TSInterface, span); - - self.ctx.write_bool(AstProp::Declare, declare); - self.ctx.write_ref(AstProp::Id, &id, ident); - self.ctx.write_maybe_ref(AstProp::Extends, &id, type_param); - self - .ctx - .write_ref_vec(AstProp::TypeParameters, &id, extends); - self.ctx.write_ref(AstProp::Body, &id, body); - - self.ctx.commit_node(id) - } - pub fn write_ts_interface_decl( &mut self, span: &Span, @@ -2214,10 +2325,10 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Declare, declare); self.ctx.write_ref(AstProp::Id, &id, ident); - self.ctx.write_maybe_ref(AstProp::Extends, &id, type_param); self .ctx - .write_ref_vec(AstProp::TypeParameters, &id, extends); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_param); + self.ctx.write_ref_vec(AstProp::Extends, &id, extends); self.ctx.write_ref(AstProp::Body, &id, body); self.ctx.commit_node(id) @@ -2245,7 +2356,7 @@ impl TsEsTreeBuilder { .append_node(AstNode::TSConstructSignatureDeclaration, span); self .ctx - .write_maybe_ref(AstProp::TypeParameters, &id, type_params); + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.write_ref_vec(AstProp::Params, &id, params); self.ctx.write_ref(AstProp::ReturnType, &id, return_type); self.ctx.commit_node(id) @@ -2263,11 +2374,13 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Optional, false); self.ctx.write_bool(AstProp::Readonly, false); self.ctx.write_bool(AstProp::Static, false); - self.ctx.write_str(AstProp::Kind, "getter"); + self.ctx.write_str(AstProp::Kind, "get"); self.ctx.write_ref(AstProp::Key, &id, key); + self.ctx.write_ref_vec(AstProp::Params, &id, vec![]); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); + self.ctx.write_undefined(AstProp::TypeParameters); self.ctx.commit_node(id) } @@ -2284,9 +2397,11 @@ impl TsEsTreeBuilder { self.ctx.write_bool(AstProp::Optional, false); self.ctx.write_bool(AstProp::Readonly, false); self.ctx.write_bool(AstProp::Static, false); - self.ctx.write_str(AstProp::Kind, "setter"); + self.ctx.write_str(AstProp::Kind, "set"); self.ctx.write_ref(AstProp::Key, &id, key); self.ctx.write_ref_vec(AstProp::Params, &id, vec![param]); + self.ctx.write_undefined(AstProp::ReturnType); + self.ctx.write_undefined(AstProp::TypeParameters); self.ctx.commit_node(id) } @@ -2316,7 +2431,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref_vec(AstProp::Params, &id, params); self .ctx - .write_maybe_ref(AstProp::ReturnType, &id, return_type); + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); self.ctx.commit_node(id) } @@ -2332,7 +2447,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::Expression, &id, expr); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_args); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_args); self.ctx.commit_node(id) } @@ -2340,17 +2455,19 @@ impl TsEsTreeBuilder { pub fn write_ts_index_sig( &mut self, span: &Span, + is_static: bool, is_readonly: bool, params: Vec, type_ann: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::TSIndexSignature, span); + self.ctx.write_bool(AstProp::Static, is_static); self.ctx.write_bool(AstProp::Readonly, is_readonly); self.ctx.write_ref_vec(AstProp::Parameters, &id, params); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) } @@ -2466,6 +2583,7 @@ impl TsEsTreeBuilder { self.ctx.commit_node(id) } + #[allow(clippy::too_many_arguments)] pub fn write_ts_mapped_type( &mut self, span: &Span, @@ -2473,7 +2591,8 @@ impl TsEsTreeBuilder { optional: Option, name: Option, type_ann: Option, - type_param: NodeRef, + key: NodeRef, + constraint: NodeRef, ) -> NodeRef { let id = self.ctx.append_node(AstNode::TSMappedType, span); @@ -2482,8 +2601,9 @@ impl TsEsTreeBuilder { self.ctx.write_maybe_ref(AstProp::NameType, &id, name); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); - self.ctx.write_ref(AstProp::TypeParameter, &id, type_param); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); + self.ctx.write_ref(AstProp::Key, &id, key); + self.ctx.write_ref(AstProp::Constraint, &id, constraint); self.ctx.commit_node(id) } @@ -2559,7 +2679,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::ExprName, &id, expr_name); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_arg); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_arg); self.ctx.commit_node(id) } @@ -2575,7 +2695,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::TypeName, &id, type_name); self .ctx - .write_maybe_ref(AstProp::TypeArguments, &id, type_arg); + .write_maybe_undef_ref(AstProp::TypeArguments, &id, type_arg); self.ctx.commit_node(id) } @@ -2593,7 +2713,7 @@ impl TsEsTreeBuilder { self.ctx.write_ref(AstProp::ParameterName, &id, param_name); self .ctx - .write_maybe_ref(AstProp::TypeAnnotation, &id, type_ann); + .write_maybe_undef_ref(AstProp::TypeAnnotation, &id, type_ann); self.ctx.commit_node(id) } @@ -2617,9 +2737,11 @@ impl TsEsTreeBuilder { span: &Span, label: NodeRef, elem_type: NodeRef, + optional: bool, ) -> NodeRef { let id = self.ctx.append_node(AstNode::TSNamedTupleMember, span); + self.ctx.write_bool(AstProp::Optional, optional); self.ctx.write_ref(AstProp::Label, &id, label); self.ctx.write_ref(AstProp::ElementType, &id, elem_type); @@ -2692,10 +2814,18 @@ impl TsEsTreeBuilder { pub fn write_ts_fn_type( &mut self, span: &Span, + type_params: Option, params: Vec, + return_type: Option, ) -> NodeRef { let id = self.ctx.append_node(AstNode::TSFunctionType, span); self.ctx.write_ref_vec(AstProp::Params, &id, params); + self + .ctx + .write_maybe_undef_ref(AstProp::ReturnType, &id, return_type); + self + .ctx + .write_maybe_undef_ref(AstProp::TypeParameters, &id, type_params); self.ctx.commit_node(id) } @@ -2751,3 +2881,25 @@ pub enum TsKeywordKind { Never, Intrinsic, } + +#[derive(Debug)] +pub enum TsModuleKind { + Global, + Namespace, + Module, +} + +#[derive(Debug)] +pub enum PropertyKind { + Get, + Init, + Set, +} + +#[derive(Debug)] +pub enum MethodKind { + Constructor, + Get, + Method, + Set, +} diff --git a/tests/unit/__snapshots__/lint_plugin_test.ts.snap b/tests/unit/__snapshots__/lint_plugin_test.ts.snap index d2a0d2aa8ce001..223f3f39e0d3c7 100644 --- a/tests/unit/__snapshots__/lint_plugin_test.ts.snap +++ b/tests/unit/__snapshots__/lint_plugin_test.ts.snap @@ -61,7 +61,7 @@ snapshot[`Plugin - ImportDeclaration 2`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 7, @@ -101,7 +101,7 @@ snapshot[`Plugin - ImportDeclaration 3`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 7, @@ -142,7 +142,7 @@ snapshot[`Plugin - ImportDeclaration 4`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, local: { name: "foo", @@ -152,7 +152,7 @@ snapshot[`Plugin - ImportDeclaration 4`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, @@ -170,7 +170,7 @@ snapshot[`Plugin - ImportDeclaration 4`] = ` 17, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, local: { name: "baz", @@ -180,7 +180,7 @@ snapshot[`Plugin - ImportDeclaration 4`] = ` 24, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 14, @@ -205,7 +205,7 @@ snapshot[`Plugin - ImportDeclaration 5`] = ` 33, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 29, @@ -247,7 +247,7 @@ snapshot[`Plugin - ImportDeclaration 5`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 7, @@ -263,6 +263,8 @@ snapshot[`Plugin - ImportDeclaration 5`] = ` snapshot[`Plugin - ExportNamedDeclaration 1`] = ` { attributes: [], + declaration: null, + exportKind: "value", range: [ 0, 26, @@ -287,7 +289,7 @@ snapshot[`Plugin - ExportNamedDeclaration 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, local: { name: "foo", @@ -297,7 +299,7 @@ snapshot[`Plugin - ExportNamedDeclaration 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, @@ -313,6 +315,8 @@ snapshot[`Plugin - ExportNamedDeclaration 1`] = ` snapshot[`Plugin - ExportNamedDeclaration 2`] = ` { attributes: [], + declaration: null, + exportKind: "value", range: [ 0, 33, @@ -337,7 +341,7 @@ snapshot[`Plugin - ExportNamedDeclaration 2`] = ` 19, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, local: { name: "bar", @@ -347,7 +351,7 @@ snapshot[`Plugin - ExportNamedDeclaration 2`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, @@ -372,7 +376,7 @@ snapshot[`Plugin - ExportNamedDeclaration 3`] = ` 37, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 33, @@ -390,6 +394,8 @@ snapshot[`Plugin - ExportNamedDeclaration 3`] = ` }, }, ], + declaration: null, + exportKind: "value", range: [ 0, 48, @@ -414,7 +420,7 @@ snapshot[`Plugin - ExportNamedDeclaration 3`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, local: { name: "foo", @@ -424,7 +430,7 @@ snapshot[`Plugin - ExportNamedDeclaration 3`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, @@ -459,16 +465,16 @@ snapshot[`Plugin - ExportDefaultDeclaration 1`] = ` 27, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, params: [], range: [ 15, 32, ], - returnType: null, + returnType: undefined, type: "FunctionDeclaration", - typeParameters: null, + typeParameters: undefined, }, exportKind: "value", range: [ @@ -499,9 +505,9 @@ snapshot[`Plugin - ExportDefaultDeclaration 2`] = ` 15, 29, ], - returnType: null, + returnType: undefined, type: "FunctionDeclaration", - typeParameters: null, + typeParameters: undefined, }, exportKind: "value", range: [ @@ -533,7 +539,7 @@ snapshot[`Plugin - ExportDefaultDeclaration 3`] = ` 24, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, implements: [], range: [ @@ -593,7 +599,7 @@ snapshot[`Plugin - ExportDefaultDeclaration 5`] = ` 18, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, exportKind: "value", range: [ @@ -616,7 +622,7 @@ snapshot[`Plugin - ExportDefaultDeclaration 6`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "Foo", optional: false, @@ -625,14 +631,14 @@ snapshot[`Plugin - ExportDefaultDeclaration 6`] = ` 28, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 15, 31, ], type: "TSInterfaceDeclaration", - typeParameters: [], + typeParameters: undefined, }, exportKind: "type", range: [ @@ -690,7 +696,7 @@ snapshot[`Plugin - ExportAllDeclaration 2`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ExportAllDeclaration", } @@ -708,7 +714,7 @@ snapshot[`Plugin - ExportAllDeclaration 3`] = ` 31, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 27, @@ -755,7 +761,7 @@ snapshot[`Plugin - TSExportAssignment 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -775,7 +781,7 @@ snapshot[`Plugin - TSNamespaceExportDeclaration 1`] = ` 21, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -795,7 +801,7 @@ snapshot[`Plugin - TSImportEqualsDeclaration 1`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, importKind: "value", moduleReference: { @@ -806,7 +812,7 @@ snapshot[`Plugin - TSImportEqualsDeclaration 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -826,7 +832,7 @@ snapshot[`Plugin - TSImportEqualsDeclaration 2`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, importKind: "value", moduleReference: { @@ -865,7 +871,7 @@ snapshot[`Plugin - BlockStatement 1`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 2, @@ -903,7 +909,7 @@ snapshot[`Plugin - BreakStatement 2`] = ` 28, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 19, @@ -934,7 +940,7 @@ snapshot[`Plugin - ContinueStatement 2`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -976,7 +982,7 @@ snapshot[`Plugin - DoWhileStatement 1`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "DoWhileStatement", } @@ -992,7 +998,7 @@ snapshot[`Plugin - ExpressionStatement 1`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1020,7 +1026,7 @@ snapshot[`Plugin - ForInStatement 1`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1034,7 +1040,7 @@ snapshot[`Plugin - ForInStatement 1`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ForInStatement", } @@ -1059,7 +1065,7 @@ snapshot[`Plugin - ForOfStatement 1`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1073,7 +1079,7 @@ snapshot[`Plugin - ForOfStatement 1`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ForOfStatement", } @@ -1098,7 +1104,7 @@ snapshot[`Plugin - ForOfStatement 2`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1112,7 +1118,7 @@ snapshot[`Plugin - ForOfStatement 2`] = ` 17, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ForOfStatement", } @@ -1157,7 +1163,7 @@ snapshot[`Plugin - ForStatement 2`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1171,7 +1177,7 @@ snapshot[`Plugin - ForStatement 2`] = ` 9, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ForStatement", update: { @@ -1182,7 +1188,7 @@ snapshot[`Plugin - ForStatement 2`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, } `; @@ -1210,7 +1216,7 @@ snapshot[`Plugin - IfStatement 1`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "IfStatement", } @@ -1246,7 +1252,7 @@ snapshot[`Plugin - IfStatement 2`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "IfStatement", } @@ -1270,7 +1276,7 @@ snapshot[`Plugin - LabeledStatement 1`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1301,7 +1307,7 @@ snapshot[`Plugin - ReturnStatement 2`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1328,7 +1334,7 @@ snapshot[`Plugin - SwitchStatement 1`] = ` 29, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "SwitchCase", }, @@ -1355,7 +1361,7 @@ snapshot[`Plugin - SwitchStatement 1`] = ` 45, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "SwitchCase", }, @@ -1386,7 +1392,7 @@ snapshot[`Plugin - SwitchStatement 1`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1406,7 +1412,7 @@ snapshot[`Plugin - ThrowStatement 1`] = ` 9, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1479,7 +1485,7 @@ snapshot[`Plugin - TryStatement 2`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 7, @@ -1544,7 +1550,7 @@ snapshot[`Plugin - WhileStatement 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "WhileStatement", } @@ -1613,9 +1619,9 @@ snapshot[`Plugin - ArrowFunctionExpression 1`] = ` 0, 8, ], - returnType: null, + returnType: undefined, type: "ArrowFunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -1636,9 +1642,9 @@ snapshot[`Plugin - ArrowFunctionExpression 2`] = ` 0, 14, ], - returnType: null, + returnType: undefined, type: "ArrowFunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -1687,7 +1693,7 @@ snapshot[`Plugin - ArrowFunctionExpression 3`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 12, @@ -1736,7 +1742,7 @@ snapshot[`Plugin - ArrowFunctionExpression 3`] = ` }, }, type: "ArrowFunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -1750,7 +1756,7 @@ snapshot[`Plugin - AssignmentExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "=", range: [ @@ -1765,7 +1771,7 @@ snapshot[`Plugin - AssignmentExpression 1`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "AssignmentExpression", } @@ -1781,7 +1787,7 @@ snapshot[`Plugin - AssignmentExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "=", range: [ @@ -1797,7 +1803,7 @@ snapshot[`Plugin - AssignmentExpression 2`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "??=", range: [ @@ -1812,7 +1818,7 @@ snapshot[`Plugin - AssignmentExpression 2`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "AssignmentExpression", }, @@ -1830,7 +1836,7 @@ snapshot[`Plugin - AwaitExpression 1`] = ` 9, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -1850,7 +1856,7 @@ snapshot[`Plugin - BinaryExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: ">", range: [ @@ -1865,7 +1871,7 @@ snapshot[`Plugin - BinaryExpression 1`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -1881,7 +1887,7 @@ snapshot[`Plugin - BinaryExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: ">=", range: [ @@ -1896,7 +1902,7 @@ snapshot[`Plugin - BinaryExpression 2`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -1912,7 +1918,7 @@ snapshot[`Plugin - BinaryExpression 3`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "<", range: [ @@ -1927,7 +1933,7 @@ snapshot[`Plugin - BinaryExpression 3`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -1943,7 +1949,7 @@ snapshot[`Plugin - BinaryExpression 4`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "<=", range: [ @@ -1958,7 +1964,7 @@ snapshot[`Plugin - BinaryExpression 4`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -1974,7 +1980,7 @@ snapshot[`Plugin - BinaryExpression 5`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "==", range: [ @@ -1989,7 +1995,7 @@ snapshot[`Plugin - BinaryExpression 5`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2005,7 +2011,7 @@ snapshot[`Plugin - BinaryExpression 6`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "===", range: [ @@ -2020,7 +2026,7 @@ snapshot[`Plugin - BinaryExpression 6`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2036,7 +2042,7 @@ snapshot[`Plugin - BinaryExpression 7`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "!=", range: [ @@ -2051,7 +2057,7 @@ snapshot[`Plugin - BinaryExpression 7`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2067,7 +2073,7 @@ snapshot[`Plugin - BinaryExpression 8`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "!=", range: [ @@ -2082,7 +2088,7 @@ snapshot[`Plugin - BinaryExpression 8`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2098,7 +2104,7 @@ snapshot[`Plugin - BinaryExpression 9`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "<<", range: [ @@ -2113,7 +2119,7 @@ snapshot[`Plugin - BinaryExpression 9`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2129,7 +2135,7 @@ snapshot[`Plugin - BinaryExpression 10`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: ">>", range: [ @@ -2144,7 +2150,7 @@ snapshot[`Plugin - BinaryExpression 10`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2160,7 +2166,7 @@ snapshot[`Plugin - BinaryExpression 11`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: ">>>", range: [ @@ -2175,7 +2181,7 @@ snapshot[`Plugin - BinaryExpression 11`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2191,7 +2197,7 @@ snapshot[`Plugin - BinaryExpression 12`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "+", range: [ @@ -2206,7 +2212,7 @@ snapshot[`Plugin - BinaryExpression 12`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2222,7 +2228,7 @@ snapshot[`Plugin - BinaryExpression 13`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "-", range: [ @@ -2237,7 +2243,7 @@ snapshot[`Plugin - BinaryExpression 13`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2253,7 +2259,7 @@ snapshot[`Plugin - BinaryExpression 14`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "*", range: [ @@ -2268,7 +2274,7 @@ snapshot[`Plugin - BinaryExpression 14`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2284,7 +2290,7 @@ snapshot[`Plugin - BinaryExpression 15`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "/", range: [ @@ -2299,7 +2305,7 @@ snapshot[`Plugin - BinaryExpression 15`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2315,7 +2321,7 @@ snapshot[`Plugin - BinaryExpression 16`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "%", range: [ @@ -2330,7 +2336,7 @@ snapshot[`Plugin - BinaryExpression 16`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2346,7 +2352,7 @@ snapshot[`Plugin - BinaryExpression 17`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "|", range: [ @@ -2361,7 +2367,7 @@ snapshot[`Plugin - BinaryExpression 17`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2377,7 +2383,7 @@ snapshot[`Plugin - BinaryExpression 18`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "^", range: [ @@ -2392,7 +2398,7 @@ snapshot[`Plugin - BinaryExpression 18`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2408,7 +2414,7 @@ snapshot[`Plugin - BinaryExpression 19`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "&", range: [ @@ -2423,7 +2429,7 @@ snapshot[`Plugin - BinaryExpression 19`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2439,7 +2445,7 @@ snapshot[`Plugin - BinaryExpression 20`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "in", range: [ @@ -2454,7 +2460,7 @@ snapshot[`Plugin - BinaryExpression 20`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2470,7 +2476,7 @@ snapshot[`Plugin - BinaryExpression 21`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "**", range: [ @@ -2485,7 +2491,7 @@ snapshot[`Plugin - BinaryExpression 21`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", } @@ -2502,7 +2508,7 @@ snapshot[`Plugin - CallExpression 1`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -2525,7 +2531,7 @@ snapshot[`Plugin - CallExpression 2`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, { argument: { @@ -2536,7 +2542,7 @@ snapshot[`Plugin - CallExpression 2`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 7, @@ -2553,7 +2559,7 @@ snapshot[`Plugin - CallExpression 2`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -2576,7 +2582,7 @@ snapshot[`Plugin - CallExpression 3`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: true, range: [ @@ -2599,7 +2605,7 @@ snapshot[`Plugin - CallExpression 4`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -2615,7 +2621,7 @@ snapshot[`Plugin - CallExpression 4`] = ` 5, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -2624,7 +2630,7 @@ snapshot[`Plugin - CallExpression 4`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -2649,7 +2655,7 @@ snapshot[`Plugin - ChainExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: true, property: { @@ -2660,7 +2666,7 @@ snapshot[`Plugin - ChainExpression 1`] = ` 4, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -2695,7 +2701,9 @@ snapshot[`Plugin - ClassExpression 1`] = ` 12, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -2719,7 +2727,7 @@ snapshot[`Plugin - ClassExpression 2`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, implements: [], range: [ @@ -2727,7 +2735,9 @@ snapshot[`Plugin - ClassExpression 2`] = ` 16, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -2751,7 +2761,7 @@ snapshot[`Plugin - ClassExpression 3`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, implements: [], range: [ @@ -2766,9 +2776,11 @@ snapshot[`Plugin - ClassExpression 3`] = ` 25, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -2792,7 +2804,7 @@ snapshot[`Plugin - ClassExpression 4`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, implements: [ { @@ -2804,14 +2816,14 @@ snapshot[`Plugin - ClassExpression 4`] = ` 40, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 37, 40, ], type: "TSClassImplements", - typeArguments: null, + typeArguments: undefined, }, { expression: { @@ -2822,14 +2834,14 @@ snapshot[`Plugin - ClassExpression 4`] = ` 46, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 42, 46, ], type: "TSClassImplements", - typeArguments: null, + typeArguments: undefined, }, ], range: [ @@ -2844,9 +2856,11 @@ snapshot[`Plugin - ClassExpression 4`] = ` 25, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -2870,7 +2884,7 @@ snapshot[`Plugin - ClassExpression 5`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, implements: [], range: [ @@ -2878,7 +2892,39 @@ snapshot[`Plugin - ClassExpression 5`] = ` 19, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: { + params: [ + { + const: false, + constraint: null, + default: null, + in: false, + name: { + name: "T", + optional: false, + range: [ + 14, + 15, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + out: false, + range: [ + 14, + 15, + ], + type: "TSTypeParameter", + }, + ], + range: [ + 13, + 16, + ], + type: "TSTypeParameterDeclaration", + }, } `; @@ -2891,6 +2937,7 @@ snapshot[`Plugin - ClassExpression 6`] = ` accessibility: undefined, computed: false, declare: false, + decorators: [], key: { name: "foo", optional: false, @@ -2899,7 +2946,7 @@ snapshot[`Plugin - ClassExpression 6`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "method", optional: false, @@ -2927,9 +2974,9 @@ snapshot[`Plugin - ClassExpression 6`] = ` 12, 20, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, }, }, ], @@ -2947,7 +2994,9 @@ snapshot[`Plugin - ClassExpression 6`] = ` 22, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -2960,6 +3009,7 @@ snapshot[`Plugin - ClassExpression 7`] = ` accessibility: undefined, computed: false, declare: false, + decorators: [], key: { name: "foo", range: [ @@ -2994,9 +3044,9 @@ snapshot[`Plugin - ClassExpression 7`] = ` 12, 21, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, }, }, ], @@ -3014,7 +3064,9 @@ snapshot[`Plugin - ClassExpression 7`] = ` 23, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3036,7 +3088,7 @@ snapshot[`Plugin - ClassExpression 8`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, override: false, @@ -3047,6 +3099,20 @@ snapshot[`Plugin - ClassExpression 8`] = ` readonly: false, static: false, type: "PropertyDefinition", + typeAnnotation: { + range: [ + 15, + 23, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 17, + 23, + ], + type: "TSNumberKeyword", + }, + }, value: null, }, ], @@ -3064,7 +3130,9 @@ snapshot[`Plugin - ClassExpression 8`] = ` 25, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3086,7 +3154,7 @@ snapshot[`Plugin - ClassExpression 9`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, override: false, @@ -3097,6 +3165,7 @@ snapshot[`Plugin - ClassExpression 9`] = ` readonly: false, static: false, type: "PropertyDefinition", + typeAnnotation: undefined, value: { name: "bar", optional: false, @@ -3105,7 +3174,7 @@ snapshot[`Plugin - ClassExpression 9`] = ` 21, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -3123,7 +3192,9 @@ snapshot[`Plugin - ClassExpression 9`] = ` 23, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3136,6 +3207,7 @@ snapshot[`Plugin - ClassExpression 10`] = ` accessibility: undefined, computed: false, declare: false, + decorators: [], key: { name: "constructor", optional: false, @@ -3144,7 +3216,7 @@ snapshot[`Plugin - ClassExpression 10`] = ` 23, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "constructor", optional: false, @@ -3208,9 +3280,9 @@ snapshot[`Plugin - ClassExpression 10`] = ` 12, 46, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, }, }, ], @@ -3228,7 +3300,9 @@ snapshot[`Plugin - ClassExpression 10`] = ` 48, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3259,6 +3333,20 @@ snapshot[`Plugin - ClassExpression 11`] = ` readonly: false, static: false, type: "PropertyDefinition", + typeAnnotation: { + range: [ + 16, + 24, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 18, + 24, + ], + type: "TSNumberKeyword", + }, + }, value: { name: "bar", optional: false, @@ -3267,7 +3355,7 @@ snapshot[`Plugin - ClassExpression 11`] = ` 30, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -3285,7 +3373,9 @@ snapshot[`Plugin - ClassExpression 11`] = ` 32, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3307,7 +3397,7 @@ snapshot[`Plugin - ClassExpression 12`] = ` 22, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, override: false, @@ -3318,6 +3408,7 @@ snapshot[`Plugin - ClassExpression 12`] = ` readonly: false, static: true, type: "PropertyDefinition", + typeAnnotation: undefined, value: { name: "bar", optional: false, @@ -3326,7 +3417,7 @@ snapshot[`Plugin - ClassExpression 12`] = ` 28, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -3344,11 +3435,87 @@ snapshot[`Plugin - ClassExpression 12`] = ` 30, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; snapshot[`Plugin - ClassExpression 13`] = ` +{ + abstract: false, + body: { + body: [ + { + parameters: [ + { + name: "key", + optional: false, + range: [ + 20, + 31, + ], + type: "Identifier", + typeAnnotation: { + range: [ + 23, + 31, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 25, + 31, + ], + type: "TSStringKeyword", + }, + }, + }, + ], + range: [ + 12, + 37, + ], + readonly: false, + static: true, + type: "TSIndexSignature", + typeAnnotation: { + range: [ + 32, + 37, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 34, + 37, + ], + type: "TSAnyKeyword", + }, + }, + }, + ], + range: [ + 4, + 39, + ], + type: "ClassBody", + }, + declare: false, + id: null, + implements: [], + range: [ + 4, + 39, + ], + superClass: null, + superTypeArguments: undefined, + type: "ClassExpression", + typeParameters: undefined, +} +`; + +snapshot[`Plugin - ClassExpression 14`] = ` { abstract: false, body: { @@ -3366,7 +3533,7 @@ snapshot[`Plugin - ClassExpression 13`] = ` 22, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, override: false, @@ -3377,6 +3544,7 @@ snapshot[`Plugin - ClassExpression 13`] = ` readonly: false, static: true, type: "PropertyDefinition", + typeAnnotation: undefined, value: null, }, { @@ -3392,7 +3560,7 @@ snapshot[`Plugin - ClassExpression 13`] = ` 36, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "=", range: [ @@ -3407,7 +3575,7 @@ snapshot[`Plugin - ClassExpression 13`] = ` 42, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "AssignmentExpression", }, @@ -3445,7 +3613,9 @@ snapshot[`Plugin - ClassExpression 13`] = ` 46, ], superClass: null, + superTypeArguments: undefined, type: "ClassExpression", + typeParameters: undefined, } `; @@ -3459,7 +3629,7 @@ snapshot[`Plugin - ConditionalExpression 1`] = ` 9, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, consequent: { name: "b", @@ -3469,7 +3639,7 @@ snapshot[`Plugin - ConditionalExpression 1`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -3483,7 +3653,7 @@ snapshot[`Plugin - ConditionalExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "ConditionalExpression", } @@ -3507,9 +3677,9 @@ snapshot[`Plugin - FunctionExpression 1`] = ` 4, 18, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -3533,16 +3703,16 @@ snapshot[`Plugin - FunctionExpression 2`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, params: [], range: [ 4, 21, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -3592,7 +3762,7 @@ snapshot[`Plugin - FunctionExpression 3`] = ` 30, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 26, @@ -3641,7 +3811,7 @@ snapshot[`Plugin - FunctionExpression 3`] = ` }, }, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -3663,9 +3833,9 @@ snapshot[`Plugin - FunctionExpression 4`] = ` 4, 25, ], - returnType: null, + returnType: undefined, type: "FunctionExpression", - typeParameters: null, + typeParameters: undefined, } `; @@ -3678,7 +3848,7 @@ snapshot[`Plugin - Identifier 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, } `; @@ -3696,7 +3866,7 @@ snapshot[`Plugin - ImportExpression 1`] = ` 20, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "init", method: false, @@ -3718,7 +3888,7 @@ snapshot[`Plugin - ImportExpression 1`] = ` 28, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "init", method: false, @@ -3780,7 +3950,7 @@ snapshot[`Plugin - LogicalExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "&&", range: [ @@ -3795,7 +3965,7 @@ snapshot[`Plugin - LogicalExpression 1`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "LogicalExpression", } @@ -3811,7 +3981,7 @@ snapshot[`Plugin - LogicalExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "||", range: [ @@ -3826,7 +3996,7 @@ snapshot[`Plugin - LogicalExpression 2`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "LogicalExpression", } @@ -3842,7 +4012,7 @@ snapshot[`Plugin - LogicalExpression 3`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "??", range: [ @@ -3857,7 +4027,7 @@ snapshot[`Plugin - LogicalExpression 3`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "LogicalExpression", } @@ -3874,7 +4044,7 @@ snapshot[`Plugin - MemberExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, property: { @@ -3885,7 +4055,7 @@ snapshot[`Plugin - MemberExpression 1`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -3906,7 +4076,7 @@ snapshot[`Plugin - MemberExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, property: { @@ -3928,6 +4098,16 @@ snapshot[`Plugin - MemberExpression 2`] = ` snapshot[`Plugin - MetaProperty 1`] = ` { + meta: { + name: "import", + optional: false, + range: [ + 0, + 11, + ], + type: "Identifier", + typeAnnotation: undefined, + }, property: { name: "meta", optional: false, @@ -3936,7 +4116,7 @@ snapshot[`Plugin - MetaProperty 1`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -3946,6 +4126,36 @@ snapshot[`Plugin - MetaProperty 1`] = ` } `; +snapshot[`Plugin - MetaProperty 2`] = ` +{ + meta: { + name: "new", + optional: false, + range: [ + 0, + 10, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + property: { + name: "target", + optional: false, + range: [ + 0, + 10, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 0, + 10, + ], + type: "MetaProperty", +} +`; + snapshot[`Plugin - NewExpression 1`] = ` { arguments: [], @@ -3957,14 +4167,14 @@ snapshot[`Plugin - NewExpression 1`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 9, ], type: "NewExpression", - typeArguments: null, + typeArguments: undefined, } `; @@ -3979,7 +4189,7 @@ snapshot[`Plugin - NewExpression 2`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, { argument: { @@ -3990,7 +4200,7 @@ snapshot[`Plugin - NewExpression 2`] = ` 18, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 14, @@ -4007,7 +4217,7 @@ snapshot[`Plugin - NewExpression 2`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -4022,7 +4232,7 @@ snapshot[`Plugin - NewExpression 2`] = ` 9, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -4031,7 +4241,7 @@ snapshot[`Plugin - NewExpression 2`] = ` 9, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -4068,7 +4278,7 @@ snapshot[`Plugin - ObjectExpression 2`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "init", method: false, @@ -4086,7 +4296,7 @@ snapshot[`Plugin - ObjectExpression 2`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -4111,7 +4321,7 @@ snapshot[`Plugin - ObjectExpression 3`] = ` 7, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "init", method: false, @@ -4129,7 +4339,7 @@ snapshot[`Plugin - ObjectExpression 3`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, { @@ -4142,7 +4352,7 @@ snapshot[`Plugin - ObjectExpression 3`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "init", method: false, @@ -4160,7 +4370,7 @@ snapshot[`Plugin - ObjectExpression 3`] = ` 18, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -4194,7 +4404,7 @@ snapshot[`Plugin - SequenceExpression 1`] = ` 2, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, { name: "b", @@ -4204,7 +4414,7 @@ snapshot[`Plugin - SequenceExpression 1`] = ` 5, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, ], range: [ @@ -4237,7 +4447,7 @@ snapshot[`Plugin - TaggedTemplateExpression 1`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, ], quasis: [ @@ -4280,10 +4490,10 @@ snapshot[`Plugin - TaggedTemplateExpression 1`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "TaggedTemplateExpression", - typeArguments: null, + typeArguments: undefined, } `; @@ -4298,7 +4508,7 @@ snapshot[`Plugin - TemplateLiteral 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, ], quasis: [ @@ -4351,7 +4561,7 @@ snapshot[`Plugin - TSAsExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -4364,7 +4574,7 @@ snapshot[`Plugin - TSAsExpression 1`] = ` 6, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "b", optional: false, @@ -4373,7 +4583,7 @@ snapshot[`Plugin - TSAsExpression 1`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -4389,7 +4599,7 @@ snapshot[`Plugin - TSAsExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -4402,7 +4612,7 @@ snapshot[`Plugin - TSAsExpression 2`] = ` 10, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "const", optional: false, @@ -4411,7 +4621,7 @@ snapshot[`Plugin - TSAsExpression 2`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -4427,7 +4637,7 @@ snapshot[`Plugin - TSNonNullExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -4447,7 +4657,7 @@ snapshot[`Plugin - TSSatisfiesExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -4460,7 +4670,7 @@ snapshot[`Plugin - TSSatisfiesExpression 1`] = ` 13, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "b", optional: false, @@ -4469,7 +4679,7 @@ snapshot[`Plugin - TSSatisfiesExpression 1`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -4485,7 +4695,7 @@ snapshot[`Plugin - UnaryExpression 1`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "typeof", range: [ @@ -4526,7 +4736,7 @@ snapshot[`Plugin - UnaryExpression 3`] = ` 2, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "-", range: [ @@ -4547,7 +4757,7 @@ snapshot[`Plugin - UnaryExpression 4`] = ` 2, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "+", range: [ @@ -4568,7 +4778,7 @@ snapshot[`Plugin - UpdateExpression 1`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "++", prefix: false, @@ -4590,7 +4800,7 @@ snapshot[`Plugin - UpdateExpression 2`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "++", prefix: true, @@ -4612,7 +4822,7 @@ snapshot[`Plugin - UpdateExpression 3`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "--", prefix: false, @@ -4634,7 +4844,7 @@ snapshot[`Plugin - UpdateExpression 4`] = ` 3, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "--", prefix: true, @@ -4656,7 +4866,7 @@ snapshot[`Plugin - YieldExpression 1`] = ` 27, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, delegate: false, range: [ @@ -4768,71 +4978,230 @@ snapshot[`Plugin - Literal 8`] = ` } `; -snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 1`] = ` +snapshot[`Plugin - Abstract class 1`] = ` { - children: [], - closingElement: null, - openingElement: { - attributes: [], - name: { - name: "div", - range: [ - 1, - 4, - ], - type: "JSXIdentifier", - }, + abstract: true, + body: { + body: [ + { + accessibility: undefined, + computed: false, + declare: false, + decorators: [], + definite: false, + key: { + name: "prop", + optional: false, + range: [ + 36, + 40, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + optional: false, + override: false, + range: [ + 27, + 49, + ], + readonly: false, + static: false, + type: "TSAbstractPropertyDefinition", + typeAnnotation: { + range: [ + 40, + 48, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 42, + 48, + ], + type: "TSStringKeyword", + }, + }, + value: null, + }, + ], range: [ 0, - 7, + 51, ], - selfClosing: true, - type: "JSXOpeningElement", - typeArguments: null, + type: "ClassBody", + }, + declare: false, + id: { + name: "SomeClass", + optional: false, + range: [ + 15, + 24, + ], + type: "Identifier", + typeAnnotation: undefined, }, + implements: [], range: [ 0, - 7, + 51, ], - type: "JSXElement", + superClass: null, + type: "ClassDeclaration", } `; -snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 2`] = ` +snapshot[`Plugin - Abstract class 2`] = ` { - children: [], - closingElement: { - name: { - name: "div", - range: [ - 7, - 10, - ], - type: "JSXIdentifier", - }, - range: [ - 5, - 11, - ], - type: "JSXClosingElement", - }, - openingElement: { - attributes: [], - name: { - name: "div", - range: [ - 1, - 4, - ], - type: "JSXIdentifier", - }, - range: [ - 0, + abstract: true, + body: { + body: [ + { + accessibility: undefined, + computed: false, + key: { + name: "method", + optional: false, + range: [ + 36, + 42, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + kind: "method", + optional: false, + override: false, + range: [ + 27, + 53, + ], + static: false, + type: "TSAbstractMethodDefinition", + value: { + async: false, + body: null, + declare: false, + expression: false, + generator: false, + id: null, + params: [], + range: [ + 27, + 53, + ], + returnType: { + range: [ + 44, + 52, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 46, + 52, + ], + type: "TSStringKeyword", + }, + }, + type: "TSEmptyBodyFunctionExpression", + typeParameters: undefined, + }, + }, + ], + range: [ + 0, + 55, + ], + type: "ClassBody", + }, + declare: false, + id: { + name: "SomeClass", + optional: false, + range: [ + 15, + 24, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + implements: [], + range: [ + 0, + 55, + ], + superClass: null, + type: "ClassDeclaration", +} +`; + +snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 1`] = ` +{ + children: [], + closingElement: null, + openingElement: { + attributes: [], + name: { + name: "div", + range: [ + 1, + 4, + ], + type: "JSXIdentifier", + }, + range: [ + 0, + 7, + ], + selfClosing: true, + type: "JSXOpeningElement", + typeArguments: undefined, + }, + range: [ + 0, + 7, + ], + type: "JSXElement", +} +`; + +snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 2`] = ` +{ + children: [], + closingElement: { + name: { + name: "div", + range: [ + 7, + 10, + ], + type: "JSXIdentifier", + }, + range: [ + 5, + 11, + ], + type: "JSXClosingElement", + }, + openingElement: { + attributes: [], + name: { + name: "div", + range: [ + 1, + 4, + ], + type: "JSXIdentifier", + }, + range: [ + 0, 5, ], selfClosing: false, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -4893,7 +5262,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: false, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -4948,7 +5317,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: true, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5010,7 +5379,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: true, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5080,7 +5449,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: false, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5125,7 +5494,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: true, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5202,7 +5571,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: true, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5232,7 +5601,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr ], selfClosing: true, type: "JSXOpeningElement", - typeArguments: null, + typeArguments: undefined, }, range: [ 0, @@ -5270,7 +5639,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 6, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -5279,7 +5648,7 @@ snapshot[`Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -5384,7 +5753,7 @@ snapshot[`Plugin - TSAsExpression 3`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5423,7 +5792,7 @@ snapshot[`Plugin - TSAsExpression 4`] = ` 14, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "const", optional: false, @@ -5432,7 +5801,7 @@ snapshot[`Plugin - TSAsExpression 4`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -5458,7 +5827,7 @@ snapshot[`Plugin - TSEnumDeclaration 1`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5488,7 +5857,7 @@ snapshot[`Plugin - TSEnumDeclaration 2`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5511,9 +5880,9 @@ snapshot[`Plugin - TSEnumDeclaration 3`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, - initializer: null, + initializer: undefined, range: [ 11, 12, @@ -5529,9 +5898,9 @@ snapshot[`Plugin - TSEnumDeclaration 3`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, - initializer: null, + initializer: undefined, range: [ 14, 15, @@ -5555,7 +5924,7 @@ snapshot[`Plugin - TSEnumDeclaration 3`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5579,7 +5948,7 @@ snapshot[`Plugin - TSEnumDeclaration 4`] = ` type: "Literal", value: "a-b", }, - initializer: null, + initializer: undefined, range: [ 11, 16, @@ -5603,7 +5972,7 @@ snapshot[`Plugin - TSEnumDeclaration 4`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5626,7 +5995,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, initializer: { range: [ @@ -5652,7 +6021,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 19, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, initializer: { range: [ @@ -5678,7 +6047,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 26, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, initializer: { left: { @@ -5689,7 +6058,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 30, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, operator: "|", range: [ @@ -5704,7 +6073,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 34, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "BinaryExpression", }, @@ -5731,7 +6100,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -5741,7 +6110,7 @@ snapshot[`Plugin - TSEnumDeclaration 5`] = ` } `; -snapshot[`Plugin - TSInterface 1`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 1`] = ` { body: { body: [], @@ -5752,7 +6121,7 @@ snapshot[`Plugin - TSInterface 1`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -5761,18 +6130,18 @@ snapshot[`Plugin - TSInterface 1`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 14, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 2`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 2`] = ` { body: { body: [], @@ -5783,7 +6152,23 @@ snapshot[`Plugin - TSInterface 2`] = ` type: "TSInterfaceBody", }, declare: false, - extends: { + extends: [], + id: { + name: "A", + optional: false, + range: [ + 10, + 11, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 0, + 17, + ], + type: "TSInterfaceDeclaration", + typeParameters: { params: [ { const: false, @@ -5798,7 +6183,7 @@ snapshot[`Plugin - TSInterface 2`] = ` 13, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -5814,26 +6199,10 @@ snapshot[`Plugin - TSInterface 2`] = ` ], type: "TSTypeParameterDeclaration", }, - id: { - name: "A", - optional: false, - range: [ - 10, - 11, - ], - type: "Identifier", - typeAnnotation: null, - }, - range: [ - 0, - 17, - ], - type: "TSInterface", - typeParameters: [], } `; -snapshot[`Plugin - TSInterface 3`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 3`] = ` { body: { body: [], @@ -5844,23 +6213,7 @@ snapshot[`Plugin - TSInterface 3`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, - id: { - name: "A", - optional: false, - range: [ - 10, - 11, - ], - type: "Identifier", - typeAnnotation: null, - }, - range: [ - 0, - 37, - ], - type: "TSInterface", - typeParameters: [ + extends: [ { expression: { name: "Foo", @@ -5870,7 +6223,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 23, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 20, @@ -5885,7 +6238,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 25, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -5894,7 +6247,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 25, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -5914,7 +6267,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 31, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 28, @@ -5929,7 +6282,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 33, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -5938,7 +6291,7 @@ snapshot[`Plugin - TSInterface 3`] = ` 33, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -5950,10 +6303,26 @@ snapshot[`Plugin - TSInterface 3`] = ` }, }, ], + id: { + name: "A", + optional: false, + range: [ + 10, + 11, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 0, + 37, + ], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 4`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 4`] = ` { body: { body: [ @@ -5967,7 +6336,7 @@ snapshot[`Plugin - TSInterface 4`] = ` 17, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -6002,7 +6371,7 @@ snapshot[`Plugin - TSInterface 4`] = ` 27, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: true, range: [ @@ -6035,7 +6404,7 @@ snapshot[`Plugin - TSInterface 4`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6044,18 +6413,18 @@ snapshot[`Plugin - TSInterface 4`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 35, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 5`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 5`] = ` { body: { body: [ @@ -6090,6 +6459,7 @@ snapshot[`Plugin - TSInterface 5`] = ` 41, ], readonly: true, + static: false, type: "TSIndexSignature", typeAnnotation: { range: [ @@ -6114,7 +6484,7 @@ snapshot[`Plugin - TSInterface 5`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6123,18 +6493,18 @@ snapshot[`Plugin - TSInterface 5`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 43, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 6`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 6`] = ` { body: { body: [ @@ -6148,7 +6518,7 @@ snapshot[`Plugin - TSInterface 6`] = ` 24, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -6181,7 +6551,7 @@ snapshot[`Plugin - TSInterface 6`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6190,18 +6560,18 @@ snapshot[`Plugin - TSInterface 6`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 31, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 7`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 7`] = ` { body: { body: [ @@ -6227,7 +6597,7 @@ snapshot[`Plugin - TSInterface 7`] = ` 22, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6236,7 +6606,7 @@ snapshot[`Plugin - TSInterface 7`] = ` 22, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, @@ -6258,7 +6628,7 @@ snapshot[`Plugin - TSInterface 7`] = ` 26, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6267,12 +6637,12 @@ snapshot[`Plugin - TSInterface 7`] = ` 26, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, type: "TSCallSignatureDeclaration", - typeAnnotation: { + typeParameters: { params: [ { const: false, @@ -6287,7 +6657,7 @@ snapshot[`Plugin - TSInterface 7`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -6312,7 +6682,7 @@ snapshot[`Plugin - TSInterface 7`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6321,18 +6691,18 @@ snapshot[`Plugin - TSInterface 7`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 28, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 8`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 8`] = ` { body: { body: [ @@ -6358,7 +6728,7 @@ snapshot[`Plugin - TSInterface 8`] = ` 26, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6367,7 +6737,7 @@ snapshot[`Plugin - TSInterface 8`] = ` 26, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, @@ -6389,7 +6759,7 @@ snapshot[`Plugin - TSInterface 8`] = ` 30, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6398,7 +6768,7 @@ snapshot[`Plugin - TSInterface 8`] = ` 30, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, @@ -6418,7 +6788,7 @@ snapshot[`Plugin - TSInterface 8`] = ` 20, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -6443,7 +6813,7 @@ snapshot[`Plugin - TSInterface 8`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6452,18 +6822,18 @@ snapshot[`Plugin - TSInterface 8`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 32, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 9`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 9`] = ` { body: { body: [ @@ -6477,7 +6847,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -6515,7 +6885,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 29, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6524,7 +6894,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 29, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, @@ -6546,7 +6916,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 35, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "T", optional: false, @@ -6555,7 +6925,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 35, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, }, @@ -6575,7 +6945,7 @@ snapshot[`Plugin - TSInterface 9`] = ` 23, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -6602,7 +6972,7 @@ snapshot[`Plugin - TSInterface 9`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6611,18 +6981,18 @@ snapshot[`Plugin - TSInterface 9`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 37, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 10`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 10`] = ` { body: { body: [ @@ -6636,10 +7006,11 @@ snapshot[`Plugin - TSInterface 10`] = ` 19, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, - kind: "getter", + kind: "get", optional: false, + params: [], range: [ 14, 29, @@ -6661,6 +7032,7 @@ snapshot[`Plugin - TSInterface 10`] = ` }, static: false, type: "TSMethodSignature", + typeParameters: undefined, }, ], range: [ @@ -6670,7 +7042,7 @@ snapshot[`Plugin - TSInterface 10`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6679,18 +7051,18 @@ snapshot[`Plugin - TSInterface 10`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 31, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 11`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 11`] = ` { body: { body: [ @@ -6704,9 +7076,9 @@ snapshot[`Plugin - TSInterface 11`] = ` 19, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, - kind: "setter", + kind: "set", optional: false, params: [ { @@ -6738,8 +7110,10 @@ snapshot[`Plugin - TSInterface 11`] = ` 30, ], readonly: false, + returnType: undefined, static: false, type: "TSMethodSignature", + typeParameters: undefined, }, ], range: [ @@ -6749,7 +7123,7 @@ snapshot[`Plugin - TSInterface 11`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6758,18 +7132,18 @@ snapshot[`Plugin - TSInterface 11`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 32, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; -snapshot[`Plugin - TSInterface 12`] = ` +snapshot[`Plugin - TSInterfaceDeclaration 12`] = ` { body: { body: [ @@ -6783,7 +7157,7 @@ snapshot[`Plugin - TSInterface 12`] = ` 15, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, kind: "method", optional: false, @@ -6820,7 +7194,7 @@ snapshot[`Plugin - TSInterface 12`] = ` 37, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 30, @@ -6886,7 +7260,7 @@ snapshot[`Plugin - TSInterface 12`] = ` 17, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -6911,7 +7285,7 @@ snapshot[`Plugin - TSInterface 12`] = ` type: "TSInterfaceBody", }, declare: false, - extends: null, + extends: [], id: { name: "A", optional: false, @@ -6920,14 +7294,14 @@ snapshot[`Plugin - TSInterface 12`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, 52, ], - type: "TSInterface", - typeParameters: [], + type: "TSInterfaceDeclaration", + typeParameters: undefined, } `; @@ -6952,7 +7326,7 @@ snapshot[`Plugin - TSSatisfiesExpression 2`] = ` 24, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "A", optional: false, @@ -6961,7 +7335,7 @@ snapshot[`Plugin - TSSatisfiesExpression 2`] = ` 24, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -6978,7 +7352,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 1`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -6992,7 +7366,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 1`] = ` ], type: "TSAnyKeyword", }, - typeParameters: null, + typeParameters: undefined, } `; @@ -7007,7 +7381,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 2`] = ` 6, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -7036,7 +7410,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 2`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -7066,7 +7440,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 3`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -7095,7 +7469,7 @@ snapshot[`Plugin - TSTypeAliasDeclaration 3`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -7124,7 +7498,7 @@ snapshot[`Plugin - TSNonNullExpression 2`] = ` 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, @@ -7148,7 +7522,7 @@ snapshot[`Plugin - TSUnionType 1`] = ` 10, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "B", optional: false, @@ -7157,7 +7531,7 @@ snapshot[`Plugin - TSUnionType 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, { @@ -7166,7 +7540,7 @@ snapshot[`Plugin - TSUnionType 1`] = ` 14, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "C", optional: false, @@ -7175,7 +7549,7 @@ snapshot[`Plugin - TSUnionType 1`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], @@ -7196,7 +7570,7 @@ snapshot[`Plugin - TSIntersectionType 1`] = ` 10, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "B", optional: false, @@ -7205,7 +7579,7 @@ snapshot[`Plugin - TSIntersectionType 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, { @@ -7214,7 +7588,7 @@ snapshot[`Plugin - TSIntersectionType 1`] = ` 14, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "C", optional: false, @@ -7223,100 +7597,526 @@ snapshot[`Plugin - TSIntersectionType 1`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, ], } `; -snapshot[`Plugin - TSModuleDeclaration 1`] = ` +snapshot[`Plugin - TSInstantiationExpression 1`] = ` { - body: { - body: [], - range: [ - 9, - 11, - ], - type: "TSModuleBlock", - }, - declare: false, - global: false, - id: { - name: "A", + expression: { + name: "a", optional: false, range: [ - 7, - 8, + 0, + 1, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 0, - 11, + 4, ], - type: "TSModuleDeclaration", -} -`; - -snapshot[`Plugin - TSModuleDeclaration 2`] = ` -{ - body: { - body: [ + type: "TSInstantiationExpression", + typeArguments: { + params: [ { - declaration: { - async: false, - body: null, - declare: false, - generator: false, - id: { - name: "A", - optional: false, - range: [ - 35, - 36, - ], - type: "Identifier", - typeAnnotation: null, - }, - params: [], + range: [ + 2, + 3, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, range: [ - 26, - 44, + 2, + 3, ], - returnType: { - range: [ - 38, - 44, - ], - type: "TSTypeAnnotation", - typeAnnotation: { - range: [ - 40, - 44, - ], - type: "TSVoidKeyword", - }, - }, - type: "FunctionDeclaration", - typeParameters: null, + type: "Identifier", + typeAnnotation: undefined, }, - range: [ - 19, - 44, - ], - type: "ExportNamedDeclaration", }, ], range: [ - 17, - 46, - ], + 1, + 4, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 2`] = ` +{ + expression: { + expression: { + name: "a", + optional: false, + range: [ + 1, + 2, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 1, + 5, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 3, + 4, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, + range: [ + 3, + 4, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 2, + 5, + ], + type: "TSTypeParameterInstantiation", + }, + }, + range: [ + 0, + 9, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 7, + 8, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "c", + optional: false, + range: [ + 7, + 8, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 6, + 9, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 3`] = ` +{ + expression: { + name: "a", + optional: false, + range: [ + 1, + 2, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 1, + 5, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 3, + 4, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, + range: [ + 3, + 4, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 2, + 5, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 4`] = ` +{ + expression: { + name: "a", + optional: false, + range: [ + 1, + 2, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 1, + 5, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 3, + 4, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, + range: [ + 3, + 4, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 2, + 5, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 5`] = ` +{ + expression: { + expression: { + name: "a", + optional: false, + range: [ + 1, + 2, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 1, + 5, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 3, + 4, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, + range: [ + 3, + 4, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 2, + 5, + ], + type: "TSTypeParameterInstantiation", + }, + }, + range: [ + 0, + 9, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 7, + 8, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "c", + optional: false, + range: [ + 7, + 8, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 6, + 9, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 6`] = ` +{ + expression: { + expression: { + computed: false, + object: { + name: "a", + optional: false, + range: [ + 1, + 2, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + optional: true, + property: { + name: "b", + optional: false, + range: [ + 4, + 5, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 1, + 5, + ], + type: "MemberExpression", + }, + range: [ + 1, + 8, + ], + type: "ChainExpression", + }, + range: [ + 1, + 8, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 6, + 7, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "c", + optional: false, + range: [ + 6, + 7, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 5, + 8, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSInstantiationExpression 7`] = ` +{ + expression: { + name: "a", + optional: false, + range: [ + 5, + 6, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + range: [ + 5, + 9, + ], + type: "TSInstantiationExpression", + typeArguments: { + params: [ + { + range: [ + 7, + 8, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "b", + optional: false, + range: [ + 7, + 8, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + ], + range: [ + 6, + 9, + ], + type: "TSTypeParameterInstantiation", + }, +} +`; + +snapshot[`Plugin - TSModuleDeclaration 1`] = ` +{ + body: { + body: [], + range: [ + 9, + 11, + ], + type: "TSModuleBlock", + }, + declare: false, + id: { + name: "A", + optional: false, + range: [ + 7, + 8, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + kind: "module", + range: [ + 0, + 11, + ], + type: "TSModuleDeclaration", +} +`; + +snapshot[`Plugin - TSModuleDeclaration 2`] = ` +{ + body: { + body: [ + { + attributes: [], + declaration: { + async: false, + body: undefined, + declare: false, + generator: false, + id: { + name: "A", + optional: false, + range: [ + 35, + 36, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + params: [], + range: [ + 26, + 44, + ], + returnType: { + range: [ + 38, + 44, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 40, + 44, + ], + type: "TSVoidKeyword", + }, + }, + type: "TSDeclareFunction", + typeParameters: undefined, + }, + exportKind: "value", + range: [ + 19, + 44, + ], + source: null, + specifiers: [], + type: "ExportNamedDeclaration", + }, + ], + range: [ + 17, + 46, + ], type: "TSModuleBlock", }, declare: true, - global: false, id: { name: "A", optional: false, @@ -7325,8 +8125,9 @@ snapshot[`Plugin - TSModuleDeclaration 2`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + kind: "module", range: [ 0, 46, @@ -7335,6 +8136,46 @@ snapshot[`Plugin - TSModuleDeclaration 2`] = ` } `; +snapshot[`Plugin - TSDeclareFunction 1`] = ` +{ + async: true, + body: undefined, + declare: false, + generator: false, + id: { + name: "foo", + optional: false, + range: [ + 15, + 18, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + params: [], + range: [ + 0, + 26, + ], + returnType: { + range: [ + 20, + 25, + ], + type: "TSTypeAnnotation", + typeAnnotation: { + range: [ + 22, + 25, + ], + type: "TSAnyKeyword", + }, + }, + type: "TSDeclareFunction", + typeParameters: undefined, +} +`; + snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 1`] = ` { body: { @@ -7346,7 +8187,6 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 1`] = ` type: "TSModuleBlock", }, declare: false, - global: false, id: { name: "A", optional: false, @@ -7355,8 +8195,9 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 1`] = ` 8, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + kind: "module", range: [ 0, 11, @@ -7379,7 +8220,6 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 2`] = ` type: "TSModuleBlock", }, declare: false, - global: false, id: { name: "B", optional: false, @@ -7388,8 +8228,9 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 2`] = ` 25, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + kind: "module", range: [ 14, 28, @@ -7404,7 +8245,6 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 2`] = ` type: "TSModuleBlock", }, declare: false, - global: false, id: { name: "A", optional: false, @@ -7413,8 +8253,9 @@ snapshot[`Plugin - TSModuleDeclaration + TSModuleBlock 2`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + kind: "module", range: [ 0, 30, @@ -7433,7 +8274,7 @@ snapshot[`Plugin - TSQualifiedName 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, @@ -7447,7 +8288,7 @@ snapshot[`Plugin - TSQualifiedName 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, type: "TSQualifiedName", } @@ -7466,7 +8307,7 @@ snapshot[`Plugin - TSTypeLiteral 1`] = ` 12, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, optional: false, range: [ @@ -7558,7 +8399,7 @@ snapshot[`Plugin - TSConditionalType 1`] = ` 10, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "B", optional: false, @@ -7567,7 +8408,7 @@ snapshot[`Plugin - TSConditionalType 1`] = ` 10, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, extendsType: { @@ -7576,7 +8417,7 @@ snapshot[`Plugin - TSConditionalType 1`] = ` 20, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "C", optional: false, @@ -7585,7 +8426,7 @@ snapshot[`Plugin - TSConditionalType 1`] = ` 20, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, falseType: { @@ -7630,7 +8471,7 @@ snapshot[`Plugin - TSInferType 1`] = ` 38, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, out: false, range: [ @@ -7656,7 +8497,7 @@ snapshot[`Plugin - TSTypeOperator 1`] = ` 16, ], type: "TSTypeReference", - typeArguments: null, + typeArguments: undefined, typeName: { name: "B", optional: false, @@ -7665,7 +8506,7 @@ snapshot[`Plugin - TSTypeOperator 1`] = ` 16, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, }, } @@ -7710,6 +8551,42 @@ snapshot[`Plugin - TSTypeOperator 3`] = ` snapshot[`Plugin - TSMappedType 1`] = ` { + constraint: { + operator: "keyof", + range: [ + 20, + 27, + ], + type: "TSTypeOperator", + typeAnnotation: { + range: [ + 26, + 27, + ], + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, + range: [ + 26, + 27, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + }, + }, + key: { + name: "P", + optional: false, + range: [ + 15, + 16, + ], + type: "Identifier", + typeAnnotation: undefined, + }, nameType: null, optional: undefined, range: [ @@ -7725,58 +8602,47 @@ snapshot[`Plugin - TSMappedType 1`] = ` ], type: "TSBooleanKeyword", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 2`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 29, + 36, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 20, - 27, + 35, + 36, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ - 26, - 27, + 35, + 36, ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 26, - 27, - ], - type: "Identifier", - typeAnnotation: null, - }, + type: "Identifier", + typeAnnotation: undefined, }, }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 15, - 16, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ - 15, - 27, + 24, + 25, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 2`] = ` -{ nameType: null, optional: undefined, range: [ @@ -7793,58 +8659,47 @@ snapshot[`Plugin - TSMappedType 2`] = ` ], type: "TSTupleType", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 3`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 30, + 37, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 29, 36, + 37, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ - 35, 36, + 37, ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 35, - 36, - ], - type: "Identifier", - typeAnnotation: null, - }, + type: "Identifier", + typeAnnotation: undefined, }, }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 24, - 25, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ - 24, - 36, + 25, + 26, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 3`] = ` -{ nameType: null, optional: undefined, range: [ @@ -7861,58 +8716,47 @@ snapshot[`Plugin - TSMappedType 3`] = ` ], type: "TSTupleType", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 4`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 30, + 37, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 30, + 36, 37, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ 36, - 37, - ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 36, - 37, - ], - type: "Identifier", - typeAnnotation: null, - }, - }, - }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 25, - 26, - ], - type: "Identifier", - typeAnnotation: null, + 37, + ], + type: "Identifier", + typeAnnotation: undefined, + }, }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ 25, - 37, + 26, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 4`] = ` -{ nameType: null, optional: undefined, range: [ @@ -7929,58 +8773,47 @@ snapshot[`Plugin - TSMappedType 4`] = ` ], type: "TSTupleType", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 5`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 20, + 27, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 30, - 37, + 26, + 27, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ - 36, - 37, + 26, + 27, ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 36, - 37, - ], - type: "Identifier", - typeAnnotation: null, - }, + type: "Identifier", + typeAnnotation: undefined, }, }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 25, - 26, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ - 25, - 37, + 15, + 16, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 5`] = ` -{ nameType: null, optional: true, range: [ @@ -7996,58 +8829,47 @@ snapshot[`Plugin - TSMappedType 5`] = ` ], type: "TSBooleanKeyword", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 6`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 20, + 27, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 20, + 26, 27, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ 26, 27, ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 26, - 27, - ], - type: "Identifier", - typeAnnotation: null, - }, + type: "Identifier", + typeAnnotation: undefined, }, }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 15, - 16, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ 15, - 27, + 16, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 6`] = ` -{ nameType: null, optional: "-", range: [ @@ -8063,58 +8885,47 @@ snapshot[`Plugin - TSMappedType 6`] = ` ], type: "TSBooleanKeyword", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", +} +`; + +snapshot[`Plugin - TSMappedType 7`] = ` +{ + constraint: { + operator: "keyof", + range: [ + 20, + 27, + ], + type: "TSTypeOperator", + typeAnnotation: { range: [ - 20, + 26, 27, ], - type: "TSTypeOperator", - typeAnnotation: { + type: "TSTypeReference", + typeArguments: undefined, + typeName: { + name: "T", + optional: false, range: [ 26, 27, ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 26, - 27, - ], - type: "Identifier", - typeAnnotation: null, - }, + type: "Identifier", + typeAnnotation: undefined, }, }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 15, - 16, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, + }, + key: { + name: "P", + optional: false, range: [ 15, - 27, + 16, ], - type: "TSTypeParameter", + type: "Identifier", + typeAnnotation: undefined, }, -} -`; - -snapshot[`Plugin - TSMappedType 7`] = ` -{ nameType: null, optional: "+", range: [ @@ -8130,53 +8941,6 @@ snapshot[`Plugin - TSMappedType 7`] = ` ], type: "TSBooleanKeyword", }, - typeParameter: { - const: false, - constraint: { - operator: "keyof", - range: [ - 20, - 27, - ], - type: "TSTypeOperator", - typeAnnotation: { - range: [ - 26, - 27, - ], - type: "TSTypeReference", - typeArguments: null, - typeName: { - name: "T", - optional: false, - range: [ - 26, - 27, - ], - type: "Identifier", - typeAnnotation: null, - }, - }, - }, - default: null, - in: false, - name: { - name: "P", - optional: false, - range: [ - 15, - 16, - ], - type: "Identifier", - typeAnnotation: null, - }, - out: false, - range: [ - 15, - 27, - ], - type: "TSTypeParameter", - }, } `; @@ -8335,8 +9099,9 @@ snapshot[`Plugin - TSTupleType + TSArrayType 2`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + optional: false, range: [ 10, 19, @@ -8371,8 +9136,9 @@ snapshot[`Plugin - TSTupleType + TSArrayType 3`] = ` 11, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, + optional: false, range: [ 10, 19, @@ -8389,6 +9155,43 @@ snapshot[`Plugin - TSTupleType + TSArrayType 3`] = ` `; snapshot[`Plugin - TSTupleType + TSArrayType 4`] = ` +{ + elementTypes: [ + { + elementType: { + range: [ + 14, + 20, + ], + type: "TSNumberKeyword", + }, + label: { + name: "x", + optional: true, + range: [ + 10, + 12, + ], + type: "Identifier", + typeAnnotation: undefined, + }, + optional: true, + range: [ + 10, + 20, + ], + type: "TSNamedTupleMember", + }, + ], + range: [ + 9, + 21, + ], + type: "TSTupleType", +} +`; + +snapshot[`Plugin - TSTupleType + TSArrayType 5`] = ` { elementTypes: [ { @@ -8415,15 +9218,16 @@ snapshot[`Plugin - TSTupleType + TSArrayType 4`] = ` 14, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 10, 15, ], type: "RestElement", - typeAnnotation: null, + typeAnnotation: undefined, }, + optional: false, range: [ 10, 24, @@ -8466,14 +9270,14 @@ snapshot[`Plugin - TSTypeQuery 1`] = ` 17, ], type: "Identifier", - typeAnnotation: null, + typeAnnotation: undefined, }, range: [ 9, 17, ], type: "TSTypeQuery", - typeArguments: null, + typeArguments: undefined, } `; diff --git a/tests/unit/lint_plugin_test.ts b/tests/unit/lint_plugin_test.ts index 4f660be29f7e49..38253fdb74a986 100644 --- a/tests/unit/lint_plugin_test.ts +++ b/tests/unit/lint_plugin_test.ts @@ -550,6 +550,11 @@ Deno.test("Plugin - ClassExpression", async (t) => { ); await testSnapshot(t, "a = class { #foo: number = bar }", "ClassExpression"); await testSnapshot(t, "a = class { static foo = bar }", "ClassExpression"); + await testSnapshot( + t, + "a = class { static [key: string]: any }", + "ClassExpression", + ); await testSnapshot( t, "a = class { static foo; static { foo = bar } }", @@ -597,6 +602,7 @@ Deno.test("Plugin - MemberExpression", async (t) => { Deno.test("Plugin - MetaProperty", async (t) => { await testSnapshot(t, "import.meta", "MetaProperty"); + await testSnapshot(t, "new.target", "MetaProperty"); }); Deno.test("Plugin - NewExpression", async (t) => { @@ -680,6 +686,36 @@ Deno.test("Plugin - Literal", async (t) => { await testSnapshot(t, "/foo/g", "Literal"); }); +// Stage 1 Proposal: https://github.com/tc39/proposal-grouped-and-auto-accessors +Deno.test.ignore( + "Plugin - AccessorProperty + TSAbstractAccessorProperty", + async (t) => { + await testSnapshot( + t, + `class Foo { accessor foo = 1; }`, + "AccessorProperty", + ); + await testSnapshot( + t, + `abstract class Foo { abstract accessor foo: number = 1; }`, + "TSAbstractAccessorProperty", + ); + }, +); + +Deno.test("Plugin - Abstract class", async (t) => { + await testSnapshot( + t, + `abstract class SomeClass { abstract prop: string; }`, + "ClassDeclaration", + ); + await testSnapshot( + t, + `abstract class SomeClass { abstract method(): string; }`, + "ClassDeclaration", + ); +}); + Deno.test("Plugin - JSXElement + JSXOpeningElement + JSXClosingElement + JSXAttr", async (t) => { await testSnapshot(t, "

", "JSXElement"); await testSnapshot(t, "
", "JSXElement"); @@ -715,28 +751,60 @@ Deno.test("Plugin - TSEnumDeclaration", async (t) => { ); }); -Deno.test("Plugin - TSInterface", async (t) => { - await testSnapshot(t, "interface A {}", "TSInterface"); - await testSnapshot(t, "interface A {}", "TSInterface"); - await testSnapshot(t, "interface A extends Foo, Bar {}", "TSInterface"); - await testSnapshot(t, "interface A { foo: any, bar?: any }", "TSInterface"); +Deno.test("Plugin - TSInterfaceDeclaration", async (t) => { + await testSnapshot(t, "interface A {}", "TSInterfaceDeclaration"); + await testSnapshot(t, "interface A {}", "TSInterfaceDeclaration"); + await testSnapshot( + t, + "interface A extends Foo, Bar {}", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { foo: any, bar?: any }", + "TSInterfaceDeclaration", + ); await testSnapshot( t, "interface A { readonly [key: string]: any }", - "TSInterface", + "TSInterfaceDeclaration", ); - await testSnapshot(t, "interface A { readonly a: any }", "TSInterface"); - await testSnapshot(t, "interface A { (a: T): T }", "TSInterface"); - await testSnapshot(t, "interface A { new (a: T): T }", "TSInterface"); - await testSnapshot(t, "interface A { a: new (a: T) => T }", "TSInterface"); - await testSnapshot(t, "interface A { get a(): string }", "TSInterface"); - await testSnapshot(t, "interface A { set a(v: string) }", "TSInterface"); + await testSnapshot( + t, + "interface A { readonly a: any }", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { (a: T): T }", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { new (a: T): T }", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { a: new (a: T) => T }", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { get a(): string }", + "TSInterfaceDeclaration", + ); + await testSnapshot( + t, + "interface A { set a(v: string) }", + "TSInterfaceDeclaration", + ); await testSnapshot( t, "interface A { a(arg?: any, ...args: any[]): any }", - "TSInterface", + "TSInterfaceDeclaration", ); }); @@ -762,6 +830,16 @@ Deno.test("Plugin - TSIntersectionType", async (t) => { await testSnapshot(t, "type A = B & C", "TSIntersectionType"); }); +Deno.test("Plugin - TSInstantiationExpression", async (t) => { + await testSnapshot(t, "a;", "TSInstantiationExpression"); + await testSnapshot(t, "(a);", "TSInstantiationExpression"); + await testSnapshot(t, "(a)();", "TSInstantiationExpression"); + await testSnapshot(t, "(a)();", "TSInstantiationExpression"); + await testSnapshot(t, "(a)?.();", "TSInstantiationExpression"); + await testSnapshot(t, "(a?.b)();", "TSInstantiationExpression"); + await testSnapshot(t, "new (a)();", "TSInstantiationExpression"); +}); + Deno.test("Plugin - TSModuleDeclaration", async (t) => { await testSnapshot(t, "module A {}", "TSModuleDeclaration"); await testSnapshot( @@ -771,6 +849,15 @@ Deno.test("Plugin - TSModuleDeclaration", async (t) => { ); }); +Deno.test("Plugin - TSDeclareFunction", async (t) => { + await testSnapshot( + t, + `async function foo(): any; +async function foo(): any {}`, + "TSDeclareFunction", + ); +}); + Deno.test("Plugin - TSModuleDeclaration + TSModuleBlock", async (t) => { await testSnapshot(t, "module A {}", "TSModuleDeclaration"); await testSnapshot( @@ -871,6 +958,7 @@ Deno.test("Plugin - TSTupleType + TSArrayType", async (t) => { await testSnapshot(t, "type A = [number]", "TSTupleType"); await testSnapshot(t, "type A = [x: number]", "TSTupleType"); await testSnapshot(t, "type A = [x: number]", "TSTupleType"); + await testSnapshot(t, "type A = [x?: number]", "TSTupleType"); await testSnapshot(t, "type A = [...x: number[]]", "TSTupleType"); }); From a0c5ef8ba8f45ec7821df5df82976670570e0a83 Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Fri, 7 Feb 2025 01:23:10 +0200 Subject: [PATCH 3/6] fix(compile): never include the specified output executable in itself (#27877) --- cli/tools/compile.rs | 35 +++++++++---------- .../__test__.jsonc | 13 +++++++ .../compile1.out | 14 ++++++++ .../compile2.out | 12 +++++++ .../two_times_compile_include_all/deno.json | 3 ++ .../two_times_compile_include_all/main.ts | 1 + 6 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 tests/specs/compile/two_times_compile_include_all/__test__.jsonc create mode 100644 tests/specs/compile/two_times_compile_include_all/compile1.out create mode 100644 tests/specs/compile/two_times_compile_include_all/compile2.out create mode 100644 tests/specs/compile/two_times_compile_include_all/deno.json create mode 100644 tests/specs/compile/two_times_compile_include_all/main.ts diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index 5df399336afe3a..6183ceb9126e38 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -37,18 +37,18 @@ pub async fn compile( let binary_writer = factory.create_compile_binary_writer().await?; let http_client = factory.http_client_provider(); let entrypoint = cli_options.resolve_main_module()?; - let (module_roots, include_files) = get_module_roots_and_include_files( - entrypoint, - &compile_flags, - cli_options.initial_cwd(), - )?; - let output_path = resolve_compile_executable_output_path( http_client, &compile_flags, cli_options.initial_cwd(), ) .await?; + let (module_roots, include_files) = get_module_roots_and_include_files( + entrypoint, + &url_from_file_path(&cli_options.initial_cwd().join(&output_path))?, + &compile_flags, + cli_options.initial_cwd(), + )?; let graph = Arc::try_unwrap( module_graph_creator @@ -198,6 +198,7 @@ fn validate_output_path(output_path: &Path) -> Result<(), AnyError> { fn get_module_roots_and_include_files( entrypoint: &ModuleSpecifier, + output_url: &ModuleSpecifier, compile_flags: &CompileFlags, initial_cwd: &Path, ) -> Result<(Vec, Vec), AnyError> { @@ -226,9 +227,8 @@ fn get_module_roots_and_include_files( fn analyze_path( url: &ModuleSpecifier, - module_roots: &mut Vec, - include_files: &mut Vec, searched_paths: &mut HashSet, + mut add_url: impl FnMut(ModuleSpecifier), ) -> Result<(), AnyError> { let Ok(path) = url_to_file_path(url) else { return Ok(()); @@ -240,10 +240,7 @@ fn get_module_roots_and_include_files( } if !path.is_dir() { let url = url_from_file_path(&path)?; - include_files.push(url.clone()); - if is_module_graph_module(&url) { - module_roots.push(url); - } + add_url(url); continue; } for entry in std::fs::read_dir(&path).with_context(|| { @@ -270,12 +267,14 @@ fn get_module_roots_and_include_files( include_files.push(url); } } else { - analyze_path( - &url, - &mut module_roots, - &mut include_files, - &mut searched_paths, - )?; + analyze_path(&url, &mut searched_paths, |file_url| { + if file_url != *output_url { + include_files.push(file_url.clone()); + if is_module_graph_module(&file_url) { + module_roots.push(file_url); + } + } + })?; } } Ok((module_roots, include_files)) diff --git a/tests/specs/compile/two_times_compile_include_all/__test__.jsonc b/tests/specs/compile/two_times_compile_include_all/__test__.jsonc new file mode 100644 index 00000000000000..c9098ed00f4dba --- /dev/null +++ b/tests/specs/compile/two_times_compile_include_all/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "compile --include . main.ts", + "output": "compile1.out" + }, + { + "args": "compile --include . main.ts", + "output": "compile2.out" + } + ] +} diff --git a/tests/specs/compile/two_times_compile_include_all/compile1.out b/tests/specs/compile/two_times_compile_include_all/compile1.out new file mode 100644 index 00000000000000..7db3d2b50b1760 --- /dev/null +++ b/tests/specs/compile/two_times_compile_include_all/compile1.out @@ -0,0 +1,14 @@ +Check file:[WILDLINE]main.ts +Check file:[WILDLINE]deno.json +Compile file:[WILDLINE]main.ts to [WILDLINE] + +Embedded Files + +[WILDLINE] +├── deno.json ([WILDLINE]) +└── main.ts ([WILDLINE]) + +Files: [WILDCARD] +Metadata: [WILDCARD] +Remote modules: [WILDCARD] + diff --git a/tests/specs/compile/two_times_compile_include_all/compile2.out b/tests/specs/compile/two_times_compile_include_all/compile2.out new file mode 100644 index 00000000000000..01871fa9745958 --- /dev/null +++ b/tests/specs/compile/two_times_compile_include_all/compile2.out @@ -0,0 +1,12 @@ +Compile file:[WILDLINE]main.ts to [WILDLINE] + +Embedded Files + +[WILDLINE] +├── deno.json ([WILDLINE]) +└── main.ts ([WILDLINE]) + +Files: [WILDCARD] +Metadata: [WILDCARD] +Remote modules: [WILDCARD] + diff --git a/tests/specs/compile/two_times_compile_include_all/deno.json b/tests/specs/compile/two_times_compile_include_all/deno.json new file mode 100644 index 00000000000000..c0401f75f5c287 --- /dev/null +++ b/tests/specs/compile/two_times_compile_include_all/deno.json @@ -0,0 +1,3 @@ +{ + "unstable": ["kv"] +} diff --git a/tests/specs/compile/two_times_compile_include_all/main.ts b/tests/specs/compile/two_times_compile_include_all/main.ts new file mode 100644 index 00000000000000..5f64f9c196585d --- /dev/null +++ b/tests/specs/compile/two_times_compile_include_all/main.ts @@ -0,0 +1 @@ +console.log("WHATEVER"); From a82326d029042aafc0e192b7593a02943ad829c3 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 6 Feb 2025 23:24:06 -0500 Subject: [PATCH 4/6] perf(compile): use bytes already in memory after downloading executable (#28000) Not sure if this will help https://github.com/denoland/deno/issues/27988 but it's better anyway. --- cli/standalone/binary.rs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index ccd0b641852108..4d96ec8a85e352 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -16,6 +16,7 @@ use capacity_builder::BytesAppendable; use deno_ast::MediaType; use deno_ast::ModuleKind; use deno_ast::ModuleSpecifier; +use deno_cache_dir::CACHE_PERM; use deno_core::anyhow::bail; use deno_core::anyhow::Context; use deno_core::error::AnyError; @@ -46,6 +47,7 @@ use deno_lib::util::hash::FastInsecureHasher; use deno_lib::version::DENO_VERSION_INFO; use deno_npm::resolution::SerializedNpmResolutionSnapshot; use deno_npm::NpmSystemInfo; +use deno_path_util::fs::atomic_write_file_with_retries; use deno_path_util::url_from_directory_path; use deno_path_util::url_to_file_path; use deno_resolver::workspace::WorkspaceResolver; @@ -285,17 +287,17 @@ impl<'a> DenoCompileBinaryWriter<'a> { let download_directory = self.deno_dir.dl_folder_path(); let binary_path = download_directory.join(&binary_path_suffix); - if !binary_path.exists() { - self - .download_base_binary(&download_directory, &binary_path_suffix) - .await - .context("Setting up base binary.")?; - } - let read_file = |path: &Path| -> Result, AnyError> { std::fs::read(path).with_context(|| format!("Reading {}", path.display())) }; - let archive_data = read_file(&binary_path)?; + let archive_data = if binary_path.exists() { + read_file(&binary_path)? + } else { + self + .download_base_binary(&binary_path, &binary_path_suffix) + .await + .context("Setting up base binary.")? + }; let temp_dir = tempfile::TempDir::new()?; let base_binary_path = archive::unpack_into_dir(archive::UnpackArgs { exe_name: "denort", @@ -311,9 +313,9 @@ impl<'a> DenoCompileBinaryWriter<'a> { async fn download_base_binary( &self, - output_directory: &Path, + output_path: &Path, binary_path_suffix: &str, - ) -> Result<(), AnyError> { + ) -> Result, AnyError> { let download_url = format!("https://dl.deno.land/{binary_path_suffix}"); let maybe_bytes = { let progress_bars = ProgressBar::new(ProgressBarStyle::DownloadBars); @@ -340,12 +342,15 @@ impl<'a> DenoCompileBinaryWriter<'a> { std::fs::create_dir_all(dir) .with_context(|| format!("Creating {}", dir.display())) }; - create_dir_all(output_directory)?; - let output_path = output_directory.join(binary_path_suffix); create_dir_all(output_path.parent().unwrap())?; - std::fs::write(&output_path, bytes) - .with_context(|| format!("Writing {}", output_path.display()))?; - Ok(()) + atomic_write_file_with_retries( + &CliSys::default(), + output_path, + &bytes, + CACHE_PERM, + ) + .with_context(|| format!("Writing {}", output_path.display()))?; + Ok(bytes) } /// This functions creates a standalone deno binary by appending a bundle From 703fdd86071859cee452aafbd2cf9522289f7f19 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 7 Feb 2025 12:35:44 +0100 Subject: [PATCH 5/6] fix: panic with js lint plugins and invalid js syntax (#28006) Noticed that the LSP might panic during serialization when working on a file with a syntax error. This PR changes the serialization so that invalid nodes are simply serialized to the invalid node `0`. The plugin code treats the node with id `0` as an invalid node and will ignore it during visiting. I'm not sure how to write a test for the LSP. --- cli/tools/lint/ast_buffer/swc.rs | 33 +++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/cli/tools/lint/ast_buffer/swc.rs b/cli/tools/lint/ast_buffer/swc.rs index ef6fac90944893..8a319ea9eb3cbd 100644 --- a/cli/tools/lint/ast_buffer/swc.rs +++ b/cli/tools/lint/ast_buffer/swc.rs @@ -241,7 +241,10 @@ fn serialize_module_decl( // Already handled earlier ExportSpecifier::Namespace(_) => unreachable!(), // this is not syntactically valid - ExportSpecifier::Default(_) => unreachable!(), + ExportSpecifier::Default(_) => { + // Ignore syntax errors + NodeRef(0) + } } }) .collect::>(); @@ -444,7 +447,10 @@ fn serialize_import_attrs( .map(|prop| { let (key, value) = match prop { // Invalid syntax - PropOrSpread::Spread(_) => unreachable!(), + PropOrSpread::Spread(_) => { + // Ignore syntax errors + (NodeRef(0), NodeRef(0)) + } PropOrSpread::Prop(prop) => { match prop.as_ref() { Prop::Shorthand(ident) => ( @@ -459,7 +465,10 @@ fn serialize_import_attrs( Prop::Assign(_) | Prop::Getter(_) | Prop::Setter(_) - | Prop::Method(_) => unreachable!(), + | Prop::Method(_) => { + // Ignore syntax errors + (NodeRef(0), NodeRef(0)) + } } } }; @@ -770,7 +779,10 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { SimpleAssignTarget::TsInstantiation(target) => { serialize_expr(ctx, &Expr::TsInstantiation(target.clone())) } - SimpleAssignTarget::Invalid(_) => unreachable!(), + SimpleAssignTarget::Invalid(_) => { + // Ignore syntax errors + NodeRef(0) + } } } AssignTarget::Pat(target) => match target { @@ -780,7 +792,10 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { AssignTargetPat::Object(object_pat) => { serialize_pat(ctx, &Pat::Object(object_pat.clone())) } - AssignTargetPat::Invalid(_) => unreachable!(), + AssignTargetPat::Invalid(_) => { + // Ignore syntax errors + NodeRef(0) + } }, }; @@ -1101,7 +1116,8 @@ fn serialize_expr(ctx: &mut TsEsTreeBuilder, expr: &Expr) -> NodeRef { ctx.write_chain_expr(&node.span, expr) } Expr::Invalid(_) => { - unreachable!() + // Ignore syntax errors + NodeRef(0) } } } @@ -1908,7 +1924,10 @@ fn serialize_pat(ctx: &mut TsEsTreeBuilder, pat: &Pat) -> NodeRef { ctx.write_assign_pat(&node.span, left, right) } - Pat::Invalid(_) => unreachable!(), + Pat::Invalid(_) => { + // Ignore syntax errors + NodeRef(0) + } Pat::Expr(node) => serialize_expr(ctx, node), } } From 615bf8a4b073ad962d201f9b8d95cd09a7a3af8e Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 7 Feb 2025 13:01:33 +0100 Subject: [PATCH 6/6] feat(unstable): type lint plugin visitor (#28005) This PR strongly types the JS plugin visitor. ```ts export default { name: "foo", rules: { bar: { create(ctx) { return { // Plain ast node visitor Identifier(node) {}, // Exit visitor "Identifier:exit"(node) {}, // Custom selectors, `node` needs to be typed manually "FunctionDeclaration > Identifier"(node: Deno.lint.Identifier) {} } } } } } ``` Follow up to https://github.com/denoland/deno/pull/27977 --- cli/tsc/dts/lib.deno.unstable.d.ts | 407 +++++++++++++++++------------ 1 file changed, 237 insertions(+), 170 deletions(-) diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index c013295b865ad3..3ace6defab3494 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1355,16 +1355,6 @@ declare namespace Deno { */ export type Range = [number, number]; - /** - * @category Linter - * @experimental - */ - export interface Node { - type: string; - range: Range; - [key: string]: unknown; - } - /** * @category Linter * @experimental @@ -1410,12 +1400,29 @@ declare namespace Deno { report(data: ReportData): void; } + /** + * @category Linter + * @experimental + */ + export type LintVisitor = + & { + [P in Node["type"]]?: (node: Extract) => void; + } + & { + [P in Node["type"] as `${P}:exit`]?: ( + node: Extract, + ) => void; + } + & // Custom selectors which cannot be typed by us + // deno-lint-ignore no-explicit-any + Partial<{ [key: string]: (node: any) => void }>; + /** * @category Linter * @experimental */ export interface Rule { - create(ctx: RuleContext): Record void>; + create(ctx: RuleContext): LintVisitor; destroy?(ctx: RuleContext): void; } @@ -1482,7 +1489,7 @@ declare namespace Deno { */ export interface ImportSpecifier { type: "ImportSpecifier"; - range: [number, number]; + range: Range; imported: Identifier | StringLiteral; local: Identifier; importKind: "type" | "value"; @@ -1494,7 +1501,7 @@ declare namespace Deno { */ export interface ImportDefaultSpecifier { type: "ImportDefaultSpecifier"; - range: [number, number]; + range: Range; local: Identifier; } @@ -1504,7 +1511,7 @@ declare namespace Deno { */ export interface ImportNamespaceSpecifier { type: "ImportNamespaceSpecifier"; - range: [number, number]; + range: Range; local: Identifier; } @@ -1514,7 +1521,7 @@ declare namespace Deno { */ export interface ImportAttribute { type: "ImportAttribute"; - range: [number, number]; + range: Range; key: Identifier | Literal; value: Literal; } @@ -1526,7 +1533,7 @@ declare namespace Deno { */ export interface ImportDeclaration { type: "ImportDeclaration"; - range: [number, number]; + range: Range; importKind: "type" | "value"; source: StringLiteral; specifiers: Array< @@ -1543,7 +1550,7 @@ declare namespace Deno { */ export interface ExportDefaultDeclaration { type: "ExportDefaultDeclaration"; - range: [number, number]; + range: Range; declaration: | ClassDeclaration | Expression @@ -1563,7 +1570,7 @@ declare namespace Deno { */ export interface ExportNamedDeclaration { type: "ExportNamedDeclaration"; - range: [number, number]; + range: Range; exportKind: "type" | "value"; specifiers: ExportSpecifier[]; declaration: @@ -1587,7 +1594,7 @@ declare namespace Deno { */ export interface ExportAllDeclaration { type: "ExportAllDeclaration"; - range: [number, number]; + range: Range; exportKind: "type" | "value"; exported: Identifier | null; source: StringLiteral; @@ -1600,7 +1607,7 @@ declare namespace Deno { */ export interface TSNamespaceExportDeclaration { type: "TSNamespaceExportDeclaration"; - range: [number, number]; + range: Range; id: Identifier; } @@ -1610,7 +1617,7 @@ declare namespace Deno { */ export interface TSImportEqualsDeclaration { type: "TSImportEqualsDeclaration"; - range: [number, number]; + range: Range; importKind: "type" | "value"; id: Identifier; moduleReference: Identifier | TSExternalModuleReference | TSQualifiedName; @@ -1622,7 +1629,7 @@ declare namespace Deno { */ export interface TSExternalModuleReference { type: "TSExternalModuleReference"; - range: [number, number]; + range: Range; expression: StringLiteral; } @@ -1632,7 +1639,7 @@ declare namespace Deno { */ export interface ExportSpecifier { type: "ExportSpecifier"; - range: [number, number]; + range: Range; exportKind: "type" | "value"; exported: Identifier | StringLiteral; local: Identifier | StringLiteral; @@ -1645,7 +1652,7 @@ declare namespace Deno { */ export interface VariableDeclaration { type: "VariableDeclaration"; - range: [number, number]; + range: Range; declare: boolean; kind: "let" | "var" | "const" | "await using" | "using"; declarations: VariableDeclarator[]; @@ -1659,7 +1666,7 @@ declare namespace Deno { */ export interface VariableDeclarator { type: "VariableDeclarator"; - range: [number, number]; + range: Range; id: ArrayPattern | ObjectPattern | Identifier; init: Expression | null; definite: boolean; @@ -1692,7 +1699,7 @@ declare namespace Deno { */ export interface FunctionDeclaration { type: "FunctionDeclaration"; - range: [number, number]; + range: Range; declare: boolean; async: boolean; generator: boolean; @@ -1710,7 +1717,7 @@ declare namespace Deno { */ export interface Decorator { type: "Decorator"; - range: [number, number]; + range: Range; expression: | ArrayExpression | ArrayPattern @@ -1743,7 +1750,7 @@ declare namespace Deno { */ export interface ClassDeclaration { type: "ClassDeclaration"; - range: [number, number]; + range: Range; declare: boolean; abstract: boolean; id: Identifier | null; @@ -1784,7 +1791,7 @@ declare namespace Deno { */ export interface ClassExpression { type: "ClassExpression"; - range: [number, number]; + range: Range; declare: boolean; abstract: boolean; id: Identifier | null; @@ -1825,7 +1832,7 @@ declare namespace Deno { */ export interface ClassBody { type: "ClassBody"; - range: [number, number]; + range: Range; body: Array< | AccessorProperty | MethodDefinition @@ -1847,7 +1854,7 @@ declare namespace Deno { */ export interface StaticBlock { type: "StaticBlock"; - range: [number, number]; + range: Range; body: Statement[]; } @@ -1860,7 +1867,7 @@ declare namespace Deno { */ export interface AccessorProperty { type: "AccessorProperty"; - range: [number, number]; + range: Range; declare: boolean; computed: boolean; optional: boolean; @@ -1879,7 +1886,7 @@ declare namespace Deno { */ export interface PropertyDefinition { type: "PropertyDefinition"; - range: [number, number]; + range: Range; declare: boolean; computed: boolean; optional: boolean; @@ -1899,7 +1906,7 @@ declare namespace Deno { */ export interface MethodDefinition { type: "MethodDefinition"; - range: [number, number]; + range: Range; declare: boolean; computed: boolean; optional: boolean; @@ -1924,7 +1931,7 @@ declare namespace Deno { */ export interface BlockStatement { type: "BlockStatement"; - range: [number, number]; + range: Range; body: Statement[]; } @@ -1935,7 +1942,7 @@ declare namespace Deno { */ export interface DebuggerStatement { type: "DebuggerStatement"; - range: [number, number]; + range: Range; } /** @@ -1946,7 +1953,7 @@ declare namespace Deno { */ export interface WithStatement { type: "WithStatement"; - range: [number, number]; + range: Range; object: Expression; body: Statement; } @@ -1958,7 +1965,7 @@ declare namespace Deno { */ export interface ReturnStatement { type: "ReturnStatement"; - range: [number, number]; + range: Range; argument: Expression | null; } @@ -1969,7 +1976,7 @@ declare namespace Deno { */ export interface LabeledStatement { type: "LabeledStatement"; - range: [number, number]; + range: Range; label: Identifier; body: Statement; } @@ -1991,7 +1998,7 @@ declare namespace Deno { */ export interface BreakStatement { type: "BreakStatement"; - range: [number, number]; + range: Range; label: Identifier | null; } @@ -2002,7 +2009,7 @@ declare namespace Deno { */ export interface ContinueStatement { type: "ContinueStatement"; - range: [number, number]; + range: Range; label: Identifier | null; } @@ -2014,7 +2021,7 @@ declare namespace Deno { */ export interface IfStatement { type: "IfStatement"; - range: [number, number]; + range: Range; test: Expression; consequent: Statement; alternate: Statement | null; @@ -2027,7 +2034,7 @@ declare namespace Deno { */ export interface SwitchStatement { type: "SwitchStatement"; - range: [number, number]; + range: Range; discriminant: Expression; cases: SwitchCase[]; } @@ -2039,7 +2046,7 @@ declare namespace Deno { */ export interface SwitchCase { type: "SwitchCase"; - range: [number, number]; + range: Range; test: Expression | null; consequent: Statement[]; } @@ -2052,7 +2059,7 @@ declare namespace Deno { */ export interface ThrowStatement { type: "ThrowStatement"; - range: [number, number]; + range: Range; argument: Expression; } @@ -2063,7 +2070,7 @@ declare namespace Deno { */ export interface WhileStatement { type: "WhileStatement"; - range: [number, number]; + range: Range; test: Expression; body: Statement; } @@ -2075,7 +2082,7 @@ declare namespace Deno { */ export interface DoWhileStatement { type: "DoWhileStatement"; - range: [number, number]; + range: Range; test: Expression; body: Statement; } @@ -2087,7 +2094,7 @@ declare namespace Deno { */ export interface ForStatement { type: "ForStatement"; - range: [number, number]; + range: Range; init: Expression | VariableDeclaration | null; test: Expression | null; update: Expression | null; @@ -2101,7 +2108,7 @@ declare namespace Deno { */ export interface ForInStatement { type: "ForInStatement"; - range: [number, number]; + range: Range; left: Expression | VariableDeclaration; right: Expression; body: Statement; @@ -2114,7 +2121,7 @@ declare namespace Deno { */ export interface ForOfStatement { type: "ForOfStatement"; - range: [number, number]; + range: Range; await: boolean; left: Expression | VariableDeclaration; right: Expression; @@ -2128,7 +2135,7 @@ declare namespace Deno { */ export interface ExpressionStatement { type: "ExpressionStatement"; - range: [number, number]; + range: Range; expression: Expression; } @@ -2139,7 +2146,7 @@ declare namespace Deno { */ export interface TryStatement { type: "TryStatement"; - range: [number, number]; + range: Range; block: BlockStatement; handler: CatchClause | null; finalizer: BlockStatement | null; @@ -2152,7 +2159,7 @@ declare namespace Deno { */ export interface CatchClause { type: "CatchClause"; - range: [number, number]; + range: Range; param: ArrayPattern | ObjectPattern | Identifier | null; body: BlockStatement; } @@ -2164,7 +2171,7 @@ declare namespace Deno { */ export interface ArrayExpression { type: "ArrayExpression"; - range: [number, number]; + range: Range; elements: Array; } @@ -2175,7 +2182,7 @@ declare namespace Deno { */ export interface ObjectExpression { type: "ObjectExpression"; - range: [number, number]; + range: Range; properties: Array; } @@ -2186,7 +2193,7 @@ declare namespace Deno { */ export interface BinaryExpression { type: "BinaryExpression"; - range: [number, number]; + range: Range; operator: | "&" | "**" @@ -2222,7 +2229,7 @@ declare namespace Deno { */ export interface LogicalExpression { type: "LogicalExpression"; - range: [number, number]; + range: Range; operator: "&&" | "??" | "||"; left: Expression; right: Expression; @@ -2236,7 +2243,7 @@ declare namespace Deno { */ export interface FunctionExpression { type: "FunctionExpression"; - range: [number, number]; + range: Range; async: boolean; generator: boolean; id: Identifier | null; @@ -2253,7 +2260,7 @@ declare namespace Deno { */ export interface ArrowFunctionExpression { type: "ArrowFunctionExpression"; - range: [number, number]; + range: Range; async: boolean; generator: boolean; id: null; @@ -2270,7 +2277,7 @@ declare namespace Deno { */ export interface ThisExpression { type: "ThisExpression"; - range: [number, number]; + range: Range; } /** @@ -2280,7 +2287,7 @@ declare namespace Deno { */ export interface Super { type: "Super"; - range: [number, number]; + range: Range; } /** @@ -2290,7 +2297,7 @@ declare namespace Deno { */ export interface UnaryExpression { type: "UnaryExpression"; - range: [number, number]; + range: Range; operator: "!" | "+" | "~" | "-" | "delete" | "typeof" | "void"; argument: Expression; } @@ -2302,7 +2309,7 @@ declare namespace Deno { */ export interface NewExpression { type: "NewExpression"; - range: [number, number]; + range: Range; callee: Expression; typeArguments: TSTypeParameterInstantiation | undefined; arguments: Array; @@ -2315,7 +2322,7 @@ declare namespace Deno { */ export interface ImportExpression { type: "ImportExpression"; - range: [number, number]; + range: Range; source: Expression; options: Expression | null; } @@ -2327,7 +2334,7 @@ declare namespace Deno { */ export interface CallExpression { type: "CallExpression"; - range: [number, number]; + range: Range; optional: boolean; callee: Expression; typeArguments: TSTypeParameterInstantiation | null; @@ -2341,7 +2348,7 @@ declare namespace Deno { */ export interface UpdateExpression { type: "UpdateExpression"; - range: [number, number]; + range: Range; prefix: boolean; operator: "++" | "--"; argument: Expression; @@ -2354,7 +2361,7 @@ declare namespace Deno { */ export interface AssignmentExpression { type: "AssignmentExpression"; - range: [number, number]; + range: Range; operator: | "&&=" | "&=" @@ -2383,7 +2390,7 @@ declare namespace Deno { */ export interface ConditionalExpression { type: "ConditionalExpression"; - range: [number, number]; + range: Range; test: Expression; consequent: Expression; alternate: Expression; @@ -2396,7 +2403,7 @@ declare namespace Deno { */ export interface MemberExpression { type: "MemberExpression"; - range: [number, number]; + range: Range; optional: boolean; computed: boolean; object: Expression; @@ -2410,7 +2417,7 @@ declare namespace Deno { */ export interface ChainExpression { type: "ChainExpression"; - range: [number, number]; + range: Range; expression: | CallExpression | MemberExpression @@ -2424,7 +2431,7 @@ declare namespace Deno { */ export interface SequenceExpression { type: "SequenceExpression"; - range: [number, number]; + range: Range; expressions: Expression[]; } @@ -2435,7 +2442,7 @@ declare namespace Deno { */ export interface TemplateLiteral { type: "TemplateLiteral"; - range: [number, number]; + range: Range; quasis: TemplateElement[]; expressions: Expression[]; } @@ -2447,7 +2454,7 @@ declare namespace Deno { */ export interface TemplateElement { type: "TemplateElement"; - range: [number, number]; + range: Range; tail: boolean; raw: string; cooked: string; @@ -2460,7 +2467,7 @@ declare namespace Deno { */ export interface TaggedTemplateExpression { type: "TaggedTemplateExpression"; - range: [number, number]; + range: Range; tag: Expression; typeArguments: TSTypeParameterInstantiation | undefined; quasi: TemplateLiteral; @@ -2473,7 +2480,7 @@ declare namespace Deno { */ export interface YieldExpression { type: "YieldExpression"; - range: [number, number]; + range: Range; delegate: boolean; argument: Expression | null; } @@ -2485,7 +2492,7 @@ declare namespace Deno { */ export interface AwaitExpression { type: "AwaitExpression"; - range: [number, number]; + range: Range; argument: Expression; } @@ -2496,7 +2503,7 @@ declare namespace Deno { */ export interface MetaProperty { type: "MetaProperty"; - range: [number, number]; + range: Range; meta: Identifier; property: Identifier; } @@ -2509,7 +2516,7 @@ declare namespace Deno { */ export interface Identifier { type: "Identifier"; - range: [number, number]; + range: Range; name: string; optional: boolean; typeAnnotation: TSTypeAnnotation | undefined; @@ -2522,7 +2529,7 @@ declare namespace Deno { */ export interface PrivateIdentifier { type: "PrivateIdentifier"; - range: [number, number]; + range: Range; name: string; } @@ -2533,7 +2540,7 @@ declare namespace Deno { */ export interface AssignmentPattern { type: "AssignmentPattern"; - range: [number, number]; + range: Range; left: ArrayPattern | ObjectPattern | Identifier; right: Expression; } @@ -2545,7 +2552,7 @@ declare namespace Deno { */ export interface ArrayPattern { type: "ArrayPattern"; - range: [number, number]; + range: Range; optional: boolean; typeAnnotation: TSTypeAnnotation | undefined; elements: Array< @@ -2566,7 +2573,7 @@ declare namespace Deno { */ export interface ObjectPattern { type: "ObjectPattern"; - range: [number, number]; + range: Range; optional: boolean; typeAnnotation: TSTypeAnnotation | undefined; properties: Array; @@ -2579,7 +2586,7 @@ declare namespace Deno { */ export interface RestElement { type: "RestElement"; - range: [number, number]; + range: Range; typeAnnotation: TSTypeAnnotation | undefined; argument: | ArrayPattern @@ -2596,7 +2603,7 @@ declare namespace Deno { */ export interface SpreadElement { type: "SpreadElement"; - range: [number, number]; + range: Range; argument: Expression; } @@ -2606,7 +2613,7 @@ declare namespace Deno { */ export interface Property { type: "Property"; - range: [number, number]; + range: Range; shorthand: boolean; computed: boolean; method: boolean; @@ -2633,7 +2640,7 @@ declare namespace Deno { */ export interface BigIntLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: string; bigint: string; value: bigint; @@ -2646,7 +2653,7 @@ declare namespace Deno { */ export interface BooleanLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: "false" | "true"; value: boolean; } @@ -2663,7 +2670,7 @@ declare namespace Deno { */ export interface NumberLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: string; value: number; } @@ -2675,7 +2682,7 @@ declare namespace Deno { */ export interface NullLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: "null"; value: null; } @@ -2692,7 +2699,7 @@ declare namespace Deno { */ export interface StringLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: string; value: string; } @@ -2708,7 +2715,7 @@ declare namespace Deno { */ export interface RegExpLiteral { type: "Literal"; - range: [number, number]; + range: Range; raw: string; regex: { flags: string; @@ -2737,7 +2744,7 @@ declare namespace Deno { */ export interface JSXIdentifier { type: "JSXIdentifier"; - range: [number, number]; + range: Range; name: string; } @@ -2748,7 +2755,7 @@ declare namespace Deno { */ export interface JSXNamespacedName { type: "JSXNamespacedName"; - range: [number, number]; + range: Range; namespace: JSXIdentifier; name: JSXIdentifier; } @@ -2760,7 +2767,7 @@ declare namespace Deno { */ export interface JSXEmptyExpression { type: "JSXEmptyExpression"; - range: [number, number]; + range: Range; } /** @@ -2770,7 +2777,7 @@ declare namespace Deno { */ export interface JSXElement { type: "JSXElement"; - range: [number, number]; + range: Range; openingElement: JSXOpeningElement; closingElement: JSXClosingElement | null; children: JSXChild[]; @@ -2783,7 +2790,7 @@ declare namespace Deno { */ export interface JSXOpeningElement { type: "JSXOpeningElement"; - range: [number, number]; + range: Range; selfClosing: boolean; name: | JSXIdentifier @@ -2800,7 +2807,7 @@ declare namespace Deno { */ export interface JSXAttribute { type: "JSXAttribute"; - range: [number, number]; + range: Range; name: JSXIdentifier | JSXNamespacedName; value: | JSXElement @@ -2816,7 +2823,7 @@ declare namespace Deno { */ export interface JSXSpreadAttribute { type: "JSXSpreadAttribute"; - range: [number, number]; + range: Range; argument: Expression; } @@ -2828,7 +2835,7 @@ declare namespace Deno { */ export interface JSXClosingElement { type: "JSXClosingElement"; - range: [number, number]; + range: Range; name: | JSXIdentifier | JSXMemberExpression @@ -2843,7 +2850,7 @@ declare namespace Deno { */ export interface JSXFragment { type: "JSXFragment"; - range: [number, number]; + range: Range; openingFragment: JSXOpeningFragment; closingFragment: JSXClosingFragment; children: JSXChild[]; @@ -2856,7 +2863,7 @@ declare namespace Deno { */ export interface JSXOpeningFragment { type: "JSXOpeningFragment"; - range: [number, number]; + range: Range; } /** @@ -2866,7 +2873,7 @@ declare namespace Deno { */ export interface JSXClosingFragment { type: "JSXClosingFragment"; - range: [number, number]; + range: Range; } /** @@ -2876,7 +2883,7 @@ declare namespace Deno { */ export interface JSXExpressionContainer { type: "JSXExpressionContainer"; - range: [number, number]; + range: Range; expression: Expression | JSXEmptyExpression; } @@ -2887,7 +2894,7 @@ declare namespace Deno { */ export interface JSXText { type: "JSXText"; - range: [number, number]; + range: Range; raw: string; value: string; } @@ -2899,7 +2906,7 @@ declare namespace Deno { */ export interface JSXMemberExpression { type: "JSXMemberExpression"; - range: [number, number]; + range: Range; object: | JSXIdentifier | JSXMemberExpression @@ -2924,7 +2931,7 @@ declare namespace Deno { */ export interface TSModuleDeclaration { type: "TSModuleDeclaration"; - range: [number, number]; + range: Range; declare: boolean; kind: "global" | "module" | "namespace"; id: Identifier | Literal | TSQualifiedName; @@ -2938,7 +2945,7 @@ declare namespace Deno { */ export interface TSModuleBlock { type: "TSModuleBlock"; - range: [number, number]; + range: Range; body: Array< | ExportAllDeclaration | ExportDefaultDeclaration @@ -2956,7 +2963,7 @@ declare namespace Deno { */ export interface TSClassImplements { type: "TSClassImplements"; - range: [number, number]; + range: Range; expression: Expression; typeArguments: TSTypeParameterInstantiation | undefined; } @@ -2967,7 +2974,7 @@ declare namespace Deno { */ export interface TSAbstractMethodDefinition { type: "TSAbstractMethodDefinition"; - range: [number, number]; + range: Range; computed: boolean; optional: boolean; override: boolean; @@ -2984,7 +2991,7 @@ declare namespace Deno { */ export interface TSAbstractPropertyDefinition { type: "TSAbstractPropertyDefinition"; - range: [number, number]; + range: Range; computed: boolean; optional: boolean; override: boolean; @@ -3010,7 +3017,7 @@ declare namespace Deno { */ export interface TSEmptyBodyFunctionExpression { type: "TSEmptyBodyFunctionExpression"; - range: [number, number]; + range: Range; declare: boolean; expression: boolean; async: boolean; @@ -3028,7 +3035,7 @@ declare namespace Deno { */ export interface TSParameterProperty { type: "TSParameterProperty"; - range: [number, number]; + range: Range; override: boolean; readonly: boolean; static: boolean; @@ -3048,7 +3055,7 @@ declare namespace Deno { */ export interface TSCallSignatureDeclaration { type: "TSCallSignatureDeclaration"; - range: [number, number]; + range: Range; typeParameters: TSTypeParameterDeclaration | undefined; params: Parameter[]; returnType: TSTypeAnnotation | undefined; @@ -3060,7 +3067,7 @@ declare namespace Deno { */ export interface TSPropertySignature { type: "TSPropertySignature"; - range: [number, number]; + range: Range; computed: boolean; optional: boolean; readonly: boolean; @@ -3080,7 +3087,7 @@ declare namespace Deno { */ export interface TSDeclareFunction { type: "TSDeclareFunction"; - range: [number, number]; + range: Range; async: boolean; declare: boolean; generator: boolean; @@ -3100,7 +3107,7 @@ declare namespace Deno { */ export interface TSEnumDeclaration { type: "TSEnumDeclaration"; - range: [number, number]; + range: Range; declare: boolean; const: boolean; id: Identifier; @@ -3114,7 +3121,7 @@ declare namespace Deno { */ export interface TSEnumBody { type: "TSEnumBody"; - range: [number, number]; + range: Range; members: TSEnumMember[]; } @@ -3125,7 +3132,7 @@ declare namespace Deno { */ export interface TSEnumMember { type: "TSEnumMember"; - range: [number, number]; + range: Range; id: | Identifier | NumberLiteral @@ -3139,7 +3146,7 @@ declare namespace Deno { */ export interface TSTypeAssertion { type: "TSTypeAssertion"; - range: [number, number]; + range: Range; expression: Expression; typeAnnotation: TypeNode; } @@ -3150,7 +3157,7 @@ declare namespace Deno { */ export interface TSTypeParameterInstantiation { type: "TSTypeParameterInstantiation"; - range: [number, number]; + range: Range; params: TypeNode[]; } @@ -3160,7 +3167,7 @@ declare namespace Deno { */ export interface TSTypeAliasDeclaration { type: "TSTypeAliasDeclaration"; - range: [number, number]; + range: Range; declare: boolean; id: Identifier; typeParameters: TSTypeParameterDeclaration | undefined; @@ -3173,7 +3180,7 @@ declare namespace Deno { */ export interface TSSatisfiesExpression { type: "TSSatisfiesExpression"; - range: [number, number]; + range: Range; expression: Expression; typeAnnotation: TypeNode; } @@ -3184,7 +3191,7 @@ declare namespace Deno { */ export interface TSAsExpression { type: "TSAsExpression"; - range: [number, number]; + range: Range; expression: Expression; typeAnnotation: TypeNode; } @@ -3195,7 +3202,7 @@ declare namespace Deno { */ export interface TSInstantiationExpression { type: "TSInstantiationExpression"; - range: [number, number]; + range: Range; expression: Expression; typeArguments: TSTypeParameterInstantiation; } @@ -3206,7 +3213,7 @@ declare namespace Deno { */ export interface TSNonNullExpression { type: "TSNonNullExpression"; - range: [number, number]; + range: Range; expression: Expression; } @@ -3216,7 +3223,7 @@ declare namespace Deno { */ export interface TSThisType { type: "TSThisType"; - range: [number, number]; + range: Range; } /** @@ -3225,7 +3232,7 @@ declare namespace Deno { */ export interface TSInterfaceDeclaration { type: "TSInterfaceDeclaration"; - range: [number, number]; + range: Range; declare: boolean; id: Identifier; extends: TSInterfaceHeritage[]; @@ -3239,7 +3246,7 @@ declare namespace Deno { */ export interface TSInterfaceBody { type: "TSInterfaceBody"; - range: [number, number]; + range: Range; body: Array< | TSCallSignatureDeclaration | TSConstructSignatureDeclaration @@ -3255,7 +3262,7 @@ declare namespace Deno { */ export interface TSConstructSignatureDeclaration { type: "TSConstructSignatureDeclaration"; - range: [number, number]; + range: Range; typeParameters: TSTypeParameterDeclaration | undefined; params: Parameter[]; returnType: TSTypeAnnotation; @@ -3267,7 +3274,7 @@ declare namespace Deno { */ export interface TSMethodSignature { type: "TSMethodSignature"; - range: [number, number]; + range: Range; computed: boolean; optional: boolean; readonly: boolean; @@ -3285,7 +3292,7 @@ declare namespace Deno { */ export interface TSInterfaceHeritage { type: "TSInterfaceHeritage"; - range: [number, number]; + range: Range; expression: Expression; typeArguments: TSTypeParameterInstantiation | undefined; } @@ -3296,7 +3303,7 @@ declare namespace Deno { */ export interface TSIndexSignature { type: "TSIndexSignature"; - range: [number, number]; + range: Range; readonly: boolean; static: boolean; parameters: Parameter[]; @@ -3309,7 +3316,7 @@ declare namespace Deno { */ export interface TSUnionType { type: "TSUnionType"; - range: [number, number]; + range: Range; types: TypeNode[]; } @@ -3319,7 +3326,7 @@ declare namespace Deno { */ export interface TSIntersectionType { type: "TSIntersectionType"; - range: [number, number]; + range: Range; types: TypeNode[]; } @@ -3329,7 +3336,7 @@ declare namespace Deno { */ export interface TSInferType { type: "TSInferType"; - range: [number, number]; + range: Range; typeParameter: TSTypeParameter; } @@ -3339,7 +3346,7 @@ declare namespace Deno { */ export interface TSTypeOperator { type: "TSTypeOperator"; - range: [number, number]; + range: Range; operator: "keyof" | "readonly" | "unique"; typeAnnotation: TypeNode; } @@ -3350,7 +3357,7 @@ declare namespace Deno { */ export interface TSIndexedAccessType { type: "TSIndexedAccessType"; - range: [number, number]; + range: Range; indexType: TypeNode; objectType: TypeNode; } @@ -3364,7 +3371,7 @@ declare namespace Deno { */ export interface TSAnyKeyword { type: "TSAnyKeyword"; - range: [number, number]; + range: Range; } /** @@ -3373,7 +3380,7 @@ declare namespace Deno { */ export interface TSUnknownKeyword { type: "TSUnknownKeyword"; - range: [number, number]; + range: Range; } /** @@ -3382,7 +3389,7 @@ declare namespace Deno { */ export interface TSNumberKeyword { type: "TSNumberKeyword"; - range: [number, number]; + range: Range; } /** @@ -3391,7 +3398,7 @@ declare namespace Deno { */ export interface TSObjectKeyword { type: "TSObjectKeyword"; - range: [number, number]; + range: Range; } /** @@ -3400,7 +3407,7 @@ declare namespace Deno { */ export interface TSBooleanKeyword { type: "TSBooleanKeyword"; - range: [number, number]; + range: Range; } /** @@ -3409,7 +3416,7 @@ declare namespace Deno { */ export interface TSBigIntKeyword { type: "TSBigIntKeyword"; - range: [number, number]; + range: Range; } /** @@ -3418,7 +3425,7 @@ declare namespace Deno { */ export interface TSStringKeyword { type: "TSStringKeyword"; - range: [number, number]; + range: Range; } /** @@ -3427,7 +3434,7 @@ declare namespace Deno { */ export interface TSSymbolKeyword { type: "TSSymbolKeyword"; - range: [number, number]; + range: Range; } /** @@ -3436,7 +3443,7 @@ declare namespace Deno { */ export interface TSVoidKeyword { type: "TSVoidKeyword"; - range: [number, number]; + range: Range; } /** @@ -3445,7 +3452,7 @@ declare namespace Deno { */ export interface TSUndefinedKeyword { type: "TSUndefinedKeyword"; - range: [number, number]; + range: Range; } /** @@ -3454,7 +3461,7 @@ declare namespace Deno { */ export interface TSNullKeyword { type: "TSNullKeyword"; - range: [number, number]; + range: Range; } /** @@ -3463,7 +3470,7 @@ declare namespace Deno { */ export interface TSNeverKeyword { type: "TSNeverKeyword"; - range: [number, number]; + range: Range; } /** @@ -3472,7 +3479,7 @@ declare namespace Deno { */ export interface TSIntrinsicKeyword { type: "TSIntrinsicKeyword"; - range: [number, number]; + range: Range; } /** @@ -3481,7 +3488,7 @@ declare namespace Deno { */ export interface TSRestType { type: "TSRestType"; - range: [number, number]; + range: Range; typeAnnotation: TypeNode; } @@ -3491,7 +3498,7 @@ declare namespace Deno { */ export interface TSConditionalType { type: "TSConditionalType"; - range: [number, number]; + range: Range; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; @@ -3504,7 +3511,7 @@ declare namespace Deno { */ export interface TSMappedType { type: "TSMappedType"; - range: [number, number]; + range: Range; readonly: boolean; optional: boolean; nameType: TypeNode | null; @@ -3519,7 +3526,7 @@ declare namespace Deno { */ export interface TSLiteralType { type: "TSLiteralType"; - range: [number, number]; + range: Range; literal: Literal | TemplateLiteral | UnaryExpression | UpdateExpression; } @@ -3529,7 +3536,7 @@ declare namespace Deno { */ export interface TSTemplateLiteralType { type: "TSTemplateLiteralType"; - range: [number, number]; + range: Range; quasis: TemplateElement[]; types: TypeNode[]; } @@ -3540,7 +3547,7 @@ declare namespace Deno { */ export interface TSTypeLiteral { type: "TSTypeLiteral"; - range: [number, number]; + range: Range; members: Array< | TSCallSignatureDeclaration | TSConstructSignatureDeclaration @@ -3556,7 +3563,7 @@ declare namespace Deno { */ export interface TSOptionalType { type: "TSOptionalType"; - range: [number, number]; + range: Range; typeAnnotation: TypeNode; } @@ -3566,7 +3573,7 @@ declare namespace Deno { */ export interface TSTypeAnnotation { type: "TSTypeAnnotation"; - range: [number, number]; + range: Range; typeAnnotation: TypeNode; } @@ -3576,7 +3583,7 @@ declare namespace Deno { */ export interface TSArrayType { type: "TSArrayType"; - range: [number, number]; + range: Range; elementType: TypeNode; } @@ -3586,7 +3593,7 @@ declare namespace Deno { */ export interface TSTypeQuery { type: "TSTypeQuery"; - range: [number, number]; + range: Range; exprName: Identifier | ThisExpression | TSQualifiedName | TSImportType; typeArguments: TSTypeParameterInstantiation | undefined; } @@ -3597,7 +3604,7 @@ declare namespace Deno { */ export interface TSTypeReference { type: "TSTypeReference"; - range: [number, number]; + range: Range; typeName: Identifier | ThisExpression | TSQualifiedName; typeArguments: TSTypeParameterInstantiation | undefined; } @@ -3608,7 +3615,7 @@ declare namespace Deno { */ export interface TSTypePredicate { type: "TSTypePredicate"; - range: [number, number]; + range: Range; asserts: boolean; parameterName: Identifier | TSThisType; typeAnnotation: TSTypeAnnotation | undefined; @@ -3620,7 +3627,7 @@ declare namespace Deno { */ export interface TSTupleType { type: "TSTupleType"; - range: [number, number]; + range: Range; elementTypes: TypeNode[]; } @@ -3630,7 +3637,7 @@ declare namespace Deno { */ export interface TSNamedTupleMember { type: "TSNamedTupleMember"; - range: [number, number]; + range: Range; label: Identifier; elementType: TypeNode; optional: boolean; @@ -3642,7 +3649,7 @@ declare namespace Deno { */ export interface TSTypeParameterDeclaration { type: "TSTypeParameterDeclaration"; - range: [number, number]; + range: Range; params: TSTypeParameter[]; } @@ -3652,7 +3659,7 @@ declare namespace Deno { */ export interface TSTypeParameter { type: "TSTypeParameter"; - range: [number, number]; + range: Range; in: boolean; out: boolean; const: boolean; @@ -3667,7 +3674,7 @@ declare namespace Deno { */ export interface TSImportType { type: "TSImportType"; - range: [number, number]; + range: Range; argument: TypeNode; qualifier: Identifier | ThisExpression | TSQualifiedName | null; typeArguments: TSTypeParameterInstantiation | null; @@ -3679,7 +3686,7 @@ declare namespace Deno { */ export interface TSExportAssignment { type: "TSExportAssignment"; - range: [number, number]; + range: Range; expression: Expression; } @@ -3689,7 +3696,7 @@ declare namespace Deno { */ export interface TSFunctionType { type: "TSFunctionType"; - range: [number, number]; + range: Range; params: Parameter[]; returnType: TSTypeAnnotation | undefined; typeParameters: TSTypeParameterDeclaration | undefined; @@ -3701,7 +3708,7 @@ declare namespace Deno { */ export interface TSQualifiedName { type: "TSQualifiedName"; - range: [number, number]; + range: Range; left: Identifier | ThisExpression | TSQualifiedName; right: Identifier; } @@ -3829,6 +3836,66 @@ declare namespace Deno { | TSUnionType | TSUnknownKeyword | TSVoidKeyword; + + /** + * Union type of all possible AST nodes + * @category Linter + * @experimental + */ + export type Node = + | Expression + | Statement + | TypeNode + | ImportSpecifier + | ImportDefaultSpecifier + | ImportNamespaceSpecifier + | ImportAttribute + | TSExternalModuleReference + | ExportSpecifier + | VariableDeclarator + | Decorator + | ClassBody + | StaticBlock + | PropertyDefinition + | MethodDefinition + | SwitchCase + | CatchClause + | TemplateElement + | PrivateIdentifier + | AssignmentPattern + | RestElement + | SpreadElement + | Property + | JSXIdentifier + | JSXNamespacedName + | JSXEmptyExpression + | JSXOpeningElement + | JSXAttribute + | JSXSpreadAttribute + | JSXClosingElement + | JSXOpeningFragment + | JSXClosingFragment + | JSXExpressionContainer + | JSXText + | JSXMemberExpression + | TSModuleBlock + | TSClassImplements + | TSAbstractMethodDefinition + | TSAbstractPropertyDefinition + | TSEmptyBodyFunctionExpression + | TSCallSignatureDeclaration + | TSPropertySignature + | TSEnumBody + | TSEnumMember + | TSTypeParameterInstantiation + | TSInterfaceBody + | TSConstructSignatureDeclaration + | TSMethodSignature + | TSInterfaceHeritage + | TSIndexSignature + | TSTypeAnnotation + | TSTypeParameterDeclaration + | TSTypeParameter; } export {}; // only export exports