diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 46ac924f4c74..9023939ac629 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -392,7 +392,7 @@ export default util.createRule({ computed: false, method: false, shorthand: false, - }, + } as any, ], // location data diff --git a/packages/eslint-plugin/src/rules/no-untyped-public-signature.ts b/packages/eslint-plugin/src/rules/no-untyped-public-signature.ts index b72e43e4cd04..88ccd3e4a953 100644 --- a/packages/eslint-plugin/src/rules/no-untyped-public-signature.ts +++ b/packages/eslint-plugin/src/rules/no-untyped-public-signature.ts @@ -63,7 +63,7 @@ export default util.createRule({ ) { return ignoredMethods.has(node.key.quasis[0].value.raw); } - if (node.key.type === AST_NODE_TYPES.Identifier && !node.computed) { + if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) { return ignoredMethods.has(node.key.name); } diff --git a/packages/eslint-plugin/src/rules/prefer-for-of.ts b/packages/eslint-plugin/src/rules/prefer-for-of.ts index 80180415ace3..40fac431664d 100644 --- a/packages/eslint-plugin/src/rules/prefer-for-of.ts +++ b/packages/eslint-plugin/src/rules/prefer-for-of.ts @@ -149,9 +149,8 @@ export default util.createRule({ // ({ foo: a[i] }) = { foo: 0 } if ( parent.type === AST_NODE_TYPES.Property && - parent.parent !== undefined && - parent.parent.type === AST_NODE_TYPES.ObjectExpression && parent.value === node && + parent.parent?.type === AST_NODE_TYPES.ObjectExpression && isAssignee(parent.parent) ) { return true; diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index 74bc37fabbb6..10a12a950565 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -107,29 +107,16 @@ function getNameFromMember( | TSESTree.TSPropertySignature, sourceCode: TSESLint.SourceCode, ): string { - if (isLiteralOrIdentifier(member.key)) { - if (member.key.type === AST_NODE_TYPES.Identifier) { - return member.key.name; - } + if (member.key.type === AST_NODE_TYPES.Identifier) { + return member.key.name; + } + if (member.key.type === AST_NODE_TYPES.Literal) { return `${member.key.value}`; } return sourceCode.text.slice(...member.key.range); } -/** - * This covers both actual property names, as well as computed properties that are either - * an identifier or a literal at the top level. - */ -function isLiteralOrIdentifier( - node: TSESTree.Expression, -): node is TSESTree.Literal | TSESTree.Identifier { - return ( - node.type === AST_NODE_TYPES.Literal || - node.type === AST_NODE_TYPES.Identifier - ); -} - type ExcludeKeys< TObj extends Record, TKeys extends keyof TObj @@ -148,7 +135,6 @@ export { InferMessageIdsTypeFromRule, InferOptionsTypeFromRule, isDefinitionFile, - isLiteralOrIdentifier, RequireKeys, upperCaseFirst, }; diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index 39f3da70df9c..559d0637d08b 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -15814,6 +15814,411 @@ Object { } `; +exports[`typescript fixtures/basics/export-named-enum-computed-number.src 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "enum", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", + }, + "parent": undefined, + "type": "EnumName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/export-named-enum-computed-string.src 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 33, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 33, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 7, + 32, + ], + "type": "TSEnumDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "enum", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 7, + 32, + ], + "type": "TSEnumDeclaration", + }, + "parent": undefined, + "type": "EnumName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [], +} +`; + +exports[`typescript fixtures/basics/export-named-enum-computed-var-ref.src 1`] = ` +Object { + "$id": 4, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "enum", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "x": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 23, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 22, + 25, + ], + "type": "TSEnumMember", + }, + "parent": undefined, + "type": "EnumMemberName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 23, + 24, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 4, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", + }, + "parent": undefined, + "type": "EnumName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 3, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [], +} +`; + exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = ` Object { "$id": 1, @@ -20765,6 +21170,162 @@ Object { } `; +exports[`typescript fixtures/basics/new-target-in-arrow-function-body.src 1`] = ` +Object { + "$id": 4, + "block": Object { + "range": Array [ + 0, + 28, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 28, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 10, + 26, + ], + "type": "ArrowFunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 3, + }, + "identifier": Object { + "name": "b", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 10, + 26, + ], + "type": "ArrowFunctionExpression", + }, + }, + ], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 4, + }, + "variableMap": Object { + "b": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "b", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 26, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 27, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "b", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + ], + "name": "b", + "references": Array [ + Object { + "$ref": 1, + }, + ], + "scope": Object { + "$ref": 3, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [], +} +`; + exports[`typescript fixtures/basics/non-null-assertion-operator.src 1`] = ` Object { "$id": 10, diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-number.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-number.src.ts new file mode 100644 index 000000000000..5a89330975c9 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-number.src.ts @@ -0,0 +1,3 @@ +export enum Foo { + [1], +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-string.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-string.src.ts new file mode 100644 index 000000000000..0cbfb7c4fcde --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-string.src.ts @@ -0,0 +1,3 @@ +export enum Foo { + ['baz'], +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-var-ref.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-var-ref.src.ts new file mode 100644 index 000000000000..4c02bc40a944 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/export-named-enum-computed-var-ref.src.ts @@ -0,0 +1,3 @@ +export enum Foo { + [x], +} diff --git a/packages/shared-fixtures/fixtures/typescript/basics/new-target-in-arrow-function-body.src.ts b/packages/shared-fixtures/fixtures/typescript/basics/new-target-in-arrow-function-body.src.ts new file mode 100644 index 000000000000..d5368dbbe38d --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/basics/new-target-in-arrow-function-body.src.ts @@ -0,0 +1 @@ +const b = () => new.target; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index a48427d9e9ef..f36203228a22 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2489,6 +2489,9 @@ export class Converter { if (node.initializer) { result.initializer = this.convertChild(node.initializer); } + if (node.name.kind === ts.SyntaxKind.ComputedPropertyName) { + result.computed = true; + } return result; } diff --git a/packages/typescript-estree/src/semantic-or-syntactic-errors.ts b/packages/typescript-estree/src/semantic-or-syntactic-errors.ts index a8ac8728798a..d2b61efc856d 100644 --- a/packages/typescript-estree/src/semantic-or-syntactic-errors.ts +++ b/packages/typescript-estree/src/semantic-or-syntactic-errors.ts @@ -56,43 +56,45 @@ function whitelistSupportedDiagnostics( ): readonly (ts.DiagnosticWithLocation | ts.Diagnostic)[] { return diagnostics.filter(diagnostic => { switch (diagnostic.code) { - case 1013: // ts 3.2 "A rest parameter or binding pattern may not have a trailing comma." - case 1014: // ts 3.2 "A rest parameter must be last in a parameter list." - case 1044: // ts 3.2 "'{0}' modifier cannot appear on a module or namespace element." - case 1045: // ts 3.2 "A '{0}' modifier cannot be used with an interface declaration." - case 1048: // ts 3.2 "A rest parameter cannot have an initializer." - case 1049: // ts 3.2 "A 'set' accessor must have exactly one parameter." - case 1070: // ts 3.2 "'{0}' modifier cannot appear on a type member." - case 1071: // ts 3.2 "'{0}' modifier cannot appear on an index signature." - case 1085: // ts 3.2 "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." - case 1090: // ts 3.2 "'{0}' modifier cannot appear on a parameter." - case 1096: // ts 3.2 "An index signature must have exactly one parameter." - case 1097: // ts 3.2 "'{0}' list cannot be empty." - case 1098: // ts 3.3 "Type parameter list cannot be empty." - case 1099: // ts 3.3 "Type argument list cannot be empty." - case 1117: // ts 3.2 "An object literal cannot have multiple properties with the same name in strict mode." - case 1121: // ts 3.2 "Octal literals are not allowed in strict mode." - case 1123: // ts 3.2: "Variable declaration list cannot be empty." - case 1141: // ts 3.2 "String literal expected." - case 1162: // ts 3.2 "An object member cannot be declared optional." - case 1172: // ts 3.2 "'extends' clause already seen." - case 1173: // ts 3.2 "'extends' clause must precede 'implements' clause." - case 1175: // ts 3.2 "'implements' clause already seen." - case 1176: // ts 3.2 "Interface declaration cannot have 'implements' clause." - case 1190: // ts 3.2 "The variable declaration of a 'for...of' statement cannot have an initializer." - case 1200: // ts 3.2 "Line terminator not permitted before arrow." - case 1206: // ts 3.2 "Decorators are not valid here." - case 1211: // ts 3.2 "A class declaration without the 'default' modifier must have a name." - case 1242: // ts 3.2 "'abstract' modifier can only appear on a class, method, or property declaration." - case 1246: // ts 3.2 "An interface property cannot have an initializer." - case 1255: // ts 3.2 "A definite assignment assertion '!' is not permitted in this context." - case 1308: // ts 3.2 "'await' expression is only allowed within an async function." - case 2364: // ts 3.2 "The left-hand side of an assignment expression must be a variable or a property access." - case 2369: // ts 3.2 "A parameter property is only allowed in a constructor implementation." - case 2462: // ts 3.2 "A rest element must be last in a destructuring pattern." - case 8017: // ts 3.2 "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." - case 17012: // ts 3.2 "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" - case 17013: // ts 3.2 "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." + case 1013: // "A rest parameter or binding pattern may not have a trailing comma." + case 1014: // "A rest parameter must be last in a parameter list." + case 1044: // "'{0}' modifier cannot appear on a module or namespace element." + case 1045: // "A '{0}' modifier cannot be used with an interface declaration." + case 1048: // "A rest parameter cannot have an initializer." + case 1049: // "A 'set' accessor must have exactly one parameter." + case 1070: // "'{0}' modifier cannot appear on a type member." + case 1071: // "'{0}' modifier cannot appear on an index signature." + case 1085: // "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'." + case 1090: // "'{0}' modifier cannot appear on a parameter." + case 1096: // "An index signature must have exactly one parameter." + case 1097: // "'{0}' list cannot be empty." + case 1098: // "Type parameter list cannot be empty." + case 1099: // "Type argument list cannot be empty." + case 1117: // "An object literal cannot have multiple properties with the same name in strict mode." + case 1121: // "Octal literals are not allowed in strict mode." + case 1123: // "Variable declaration list cannot be empty." + case 1141: // "String literal expected." + case 1162: // "An object member cannot be declared optional." + case 1164: // "Computed property names are not allowed in enums." + case 1172: // "'extends' clause already seen." + case 1173: // "'extends' clause must precede 'implements' clause." + case 1175: // "'implements' clause already seen." + case 1176: // "Interface declaration cannot have 'implements' clause." + case 1190: // "The variable declaration of a 'for...of' statement cannot have an initializer." + case 1200: // "Line terminator not permitted before arrow." + case 1206: // "Decorators are not valid here." + case 1211: // "A class declaration without the 'default' modifier must have a name." + case 1242: // "'abstract' modifier can only appear on a class, method, or property declaration." + case 1246: // "An interface property cannot have an initializer." + case 1255: // "A definite assignment assertion '!' is not permitted in this context." + case 1308: // "'await' expression is only allowed within an async function." + case 2364: // "The left-hand side of an assignment expression must be a variable or a property access." + case 2369: // "A parameter property is only allowed in a constructor implementation." + case 2452: // "An enum member cannot have a numeric name." + case 2462: // "A rest element must be last in a destructuring pattern." + case 8017: // "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." + case 17012: // "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" + case 17013: // "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." return true; } return false; diff --git a/packages/typescript-estree/src/ts-estree/ts-estree.ts b/packages/typescript-estree/src/ts-estree/ts-estree.ts index 438730ab8fcf..153f693fdd66 100644 --- a/packages/typescript-estree/src/ts-estree/ts-estree.ts +++ b/packages/typescript-estree/src/ts-estree/ts-estree.ts @@ -254,6 +254,9 @@ export type ClassElement = | TSAbstractMethodDefinition | TSEmptyBodyFunctionExpression | TSIndexSignature; +export type ClassProperty = + | ClassPropertyComputedName + | ClassPropertyNonComputedName; export type DeclarationStatement = | ClassDeclaration | ClassExpression @@ -331,7 +334,19 @@ export type LeftHandSideExpression = | TaggedTemplateExpression | TSNonNullExpression | TSAsExpression; +export type Literal = + | BooleanLiteral + | NumberLiteral + | NullLiteral + | RegExpLiteral + | StringLiteral; export type LiteralExpression = BigIntLiteral | Literal | TemplateLiteral; +export type MemberExpression = + | MemberExpressionComputedName + | MemberExpressionNonComputedName; +export type MethodDefinition = + | MethodDefinitionComputedName + | MethodDefinitionNonComputedName; export type Modifier = | TSAbstractKeyword | TSAsyncKeyword @@ -347,6 +362,9 @@ export type ObjectLiteralElementLike = | Property | SpreadElement | TSAbstractMethodDefinition; +export type OptionalMemberExpression = + | OptionalMemberExpressionComputedName + | OptionalMemberExpressionNonComputedName; export type Parameter = | AssignmentPattern | RestElement @@ -380,7 +398,13 @@ export type PrimaryExpression = | TemplateLiteral | ThisExpression | TSNullKeyword; -export type PropertyName = Expression; +export type Property = PropertyComputedName | PropertyNonComputedName; +export type PropertyName = PropertyNameComputed | PropertyNameNonComputed; +export type PropertyNameComputed = Expression; +export type PropertyNameNonComputed = + | Identifier + | StringLiteral + | NumberLiteral; export type Statement = | BlockStatement | BreakStatement @@ -400,6 +424,27 @@ export type Statement = | TryStatement | VariableDeclaration | WithStatement; +export type TSAbstractClassProperty = + | TSAbstractClassPropertyComputedName + | TSAbstractClassPropertyNonComputedName; +export type TSAbstractMethodDefinition = + | TSAbstractMethodDefinitionComputedName + | TSAbstractMethodDefinitionNonComputedName; +export type TSMethodSignature = + | TSMethodSignatureComputedName + | TSMethodSignatureNonComputedName; +export type TSPropertySignature = + | TSPropertySignatureComputedName + | TSPropertySignatureNonComputedName; +export type TSEnumMember = + | TSEnumMemberComputedName + | TSEnumMemberNonComputedName; +export type TSUnaryExpression = + | AwaitExpression + | LeftHandSideExpression + | TSTypeAssertion + | UnaryExpression + | UpdateExpression; export type TypeElement = | TSCallSignatureDeclaration | TSConstructSignatureDeclaration @@ -443,12 +488,6 @@ export type TypeNode = | TSUnionType | TSUnknownKeyword | TSVoidKeyword; -export type TSUnaryExpression = - | AwaitExpression - | LeftHandSideExpression - | TSTypeAssertion - | UnaryExpression - | UpdateExpression; /////////////// // Base, common types @@ -461,6 +500,13 @@ interface BinaryExpressionBase extends BaseNode { right: Expression; } +interface CallExpressionBase extends BaseNode { + callee: LeftHandSideExpression; + arguments: Expression[]; + typeParameters?: TSTypeParameterInstantiation; + optional: boolean; +} + interface ClassDeclarationBase extends BaseNode { typeParameters?: TSTypeParameterDeclaration; superTypeParameters?: TSTypeParameterInstantiation; @@ -473,8 +519,9 @@ interface ClassDeclarationBase extends BaseNode { decorators?: Decorator[]; } +/** this should not be directly used - instead use ClassPropertyComputedNameBase or ClassPropertyNonComputedNameBase */ interface ClassPropertyBase extends BaseNode { - key: PropertyName; + key: PropertyNameComputed | PropertyNameComputed; value: Expression | null; computed: boolean; static: boolean; @@ -487,6 +534,16 @@ interface ClassPropertyBase extends BaseNode { typeAnnotation?: TSTypeAnnotation; } +interface ClassPropertyComputedNameBase extends ClassPropertyBase { + key: PropertyNameComputed; + computed: true; +} + +interface ClassPropertyNonComputedNameBase extends ClassPropertyBase { + key: PropertyNameNonComputed; + computed: false; +} + interface FunctionDeclarationBase extends BaseNode { id: Identifier | null; generator: boolean; @@ -514,8 +571,27 @@ interface LiteralBase extends BaseNode { }; } +/** this should not be directly used - instead use MemberExpressionComputedNameBase or MemberExpressionNonComputedNameBase */ +interface MemberExpressionBase extends BaseNode { + object: LeftHandSideExpression; + property: Expression | Identifier; + computed: boolean; + optional: boolean; +} + +interface MemberExpressionComputedNameBase extends MemberExpressionBase { + property: Expression; + computed: true; +} + +interface MemberExpressionNonComputedNameBase extends MemberExpressionBase { + property: Identifier; + computed: false; +} + +/** this should not be directly used - instead use MethodDefinitionComputedNameBase or MethodDefinitionNonComputedNameBase */ interface MethodDefinitionBase extends BaseNode { - key: PropertyName; + key: PropertyNameComputed | PropertyNameComputed; value: FunctionExpression | TSEmptyBodyFunctionExpression; computed: boolean; static: boolean; @@ -525,11 +601,68 @@ interface MethodDefinitionBase extends BaseNode { typeParameters?: TSTypeParameterDeclaration; } +interface MethodDefinitionComputedNameBase extends MethodDefinitionBase { + key: PropertyNameComputed; + computed: true; +} + +interface MethodDefinitionNonComputedNameBase extends MethodDefinitionBase { + key: PropertyNameNonComputed; + computed: false; +} + +interface PropertyBase extends BaseNode { + type: AST_NODE_TYPES.Property; + key: PropertyNameComputed | PropertyNameNonComputed; + value: Expression | AssignmentPattern | BindingName; + computed: boolean; + method: boolean; + shorthand: boolean; + kind: 'init' | 'get' | 'set'; +} + +interface TSEnumMemberBase extends BaseNode { + type: AST_NODE_TYPES.TSEnumMember; + id: + | PropertyNameNonComputed + // this should only happen in semantically invalid code (ts error 1164) + | PropertyNameComputed; + initializer?: Expression; + computed?: boolean; +} + interface TSHeritageBase extends BaseNode { expression: Expression; typeParameters?: TSTypeParameterInstantiation; } +interface TSMethodSignatureBase extends BaseNode { + type: AST_NODE_TYPES.TSMethodSignature; + key: PropertyNameComputed | PropertyNameNonComputed; + computed: boolean; + params: Parameter[]; + optional?: boolean; + returnType?: TSTypeAnnotation; + readonly?: boolean; + typeParameters?: TSTypeParameterDeclaration; + accessibility?: Accessibility; + export?: boolean; + static?: boolean; +} + +interface TSPropertySignatureBase extends BaseNode { + type: AST_NODE_TYPES.TSPropertySignature; + key: PropertyNameComputed | PropertyNameNonComputed; + optional?: boolean; + computed: boolean; + typeAnnotation?: TSTypeAnnotation; + initializer?: Expression; + readonly?: boolean; + static?: boolean; + export?: boolean; + accessibility?: Accessibility; +} + interface UnaryExpressionBase extends BaseNode { operator: string; prefix: boolean; @@ -597,25 +730,20 @@ export interface BlockStatement extends BaseNode { body: Statement[]; } +export interface BooleanLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: boolean; +} + export interface BreakStatement extends BaseNode { type: AST_NODE_TYPES.BreakStatement; label: Identifier | null; } -interface CallExpressionBase extends BaseNode { - callee: LeftHandSideExpression; - arguments: Expression[]; - typeParameters?: TSTypeParameterInstantiation; - optional: boolean; -} export interface CallExpression extends CallExpressionBase { type: AST_NODE_TYPES.CallExpression; optional: false; } -export interface OptionalCallExpression extends CallExpressionBase { - type: AST_NODE_TYPES.OptionalCallExpression; - optional: boolean; -} export interface CatchClause extends BaseNode { type: AST_NODE_TYPES.CatchClause; @@ -636,7 +764,13 @@ export interface ClassExpression extends ClassDeclarationBase { type: AST_NODE_TYPES.ClassExpression; } -export interface ClassProperty extends ClassPropertyBase { +export interface ClassPropertyComputedName + extends ClassPropertyComputedNameBase { + type: AST_NODE_TYPES.ClassProperty; +} + +export interface ClassPropertyNonComputedName + extends ClassPropertyNonComputedNameBase { type: AST_NODE_TYPES.ClassProperty; } @@ -856,27 +990,20 @@ export interface LabeledStatement extends BaseNode { body: Statement; } -export interface Literal extends LiteralBase { - type: AST_NODE_TYPES.Literal; -} - export interface LogicalExpression extends BinaryExpressionBase { type: AST_NODE_TYPES.LogicalExpression; } -interface MemberExpressionBase extends BaseNode { - object: LeftHandSideExpression; - property: Expression | Identifier; - computed: boolean; - optional: boolean; -} -export interface MemberExpression extends MemberExpressionBase { +export interface MemberExpressionComputedName + extends MemberExpressionComputedNameBase { type: AST_NODE_TYPES.MemberExpression; optional: false; } -export interface OptionalMemberExpression extends MemberExpressionBase { - type: AST_NODE_TYPES.OptionalMemberExpression; - optional: boolean; + +export interface MemberExpressionNonComputedName + extends MemberExpressionNonComputedNameBase { + type: AST_NODE_TYPES.MemberExpression; + optional: false; } export interface MetaProperty extends BaseNode { @@ -885,7 +1012,13 @@ export interface MetaProperty extends BaseNode { property: Identifier; } -export interface MethodDefinition extends MethodDefinitionBase { +export interface MethodDefinitionComputedName + extends MethodDefinitionComputedNameBase { + type: AST_NODE_TYPES.MethodDefinition; +} + +export interface MethodDefinitionNonComputedName + extends MethodDefinitionNonComputedNameBase { type: AST_NODE_TYPES.MethodDefinition; } @@ -896,6 +1029,16 @@ export interface NewExpression extends BaseNode { typeParameters?: TSTypeParameterInstantiation; } +export interface NumberLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: number; +} + +export interface NullLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: null; +} + export interface ObjectExpression extends BaseNode { type: AST_NODE_TYPES.ObjectExpression; properties: ObjectLiteralElementLike[]; @@ -909,6 +1052,23 @@ export interface ObjectPattern extends BaseNode { decorators?: Decorator[]; } +export interface OptionalCallExpression extends CallExpressionBase { + type: AST_NODE_TYPES.OptionalCallExpression; + optional: boolean; +} + +export interface OptionalMemberExpressionComputedName + extends MemberExpressionComputedNameBase { + type: AST_NODE_TYPES.OptionalMemberExpression; + optional: boolean; +} + +export interface OptionalMemberExpressionNonComputedName + extends MemberExpressionNonComputedNameBase { + type: AST_NODE_TYPES.OptionalMemberExpression; + optional: boolean; +} + export interface Program extends BaseNode { type: AST_NODE_TYPES.Program; body: Statement[]; @@ -917,14 +1077,19 @@ export interface Program extends BaseNode { tokens?: Token[]; } -export interface Property extends BaseNode { - type: AST_NODE_TYPES.Property; - key: PropertyName; - value: Expression | AssignmentPattern | BindingName; - computed: boolean; - method: boolean; - shorthand: boolean; - kind: 'init' | 'get' | 'set'; +export interface PropertyComputedName extends PropertyBase { + key: PropertyNameComputed; + computed: true; +} + +export interface PropertyNonComputedName extends PropertyBase { + key: PropertyNameNonComputed; + computed: false; +} + +export interface RegExpLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: RegExp; } export interface RestElement extends BaseNode { @@ -948,7 +1113,12 @@ export interface SequenceExpression extends BaseNode { export interface SpreadElement extends BaseNode { type: AST_NODE_TYPES.SpreadElement; - argument: BindingName | Expression | PropertyName; + argument: Expression; +} + +export interface StringLiteral extends LiteralBase { + type: AST_NODE_TYPES.Literal; + value: string; } export interface Super extends BaseNode { @@ -1005,7 +1175,13 @@ export interface TryStatement extends BaseNode { finalizer: BlockStatement; } -export interface TSAbstractClassProperty extends ClassPropertyBase { +export interface TSAbstractClassPropertyComputedName + extends ClassPropertyComputedNameBase { + type: AST_NODE_TYPES.TSAbstractClassProperty; +} + +export interface TSAbstractClassPropertyNonComputedName + extends ClassPropertyNonComputedNameBase { type: AST_NODE_TYPES.TSAbstractClassProperty; } @@ -1013,7 +1189,13 @@ export interface TSAbstractKeyword extends BaseNode { type: AST_NODE_TYPES.TSAbstractKeyword; } -export interface TSAbstractMethodDefinition extends MethodDefinitionBase { +export interface TSAbstractMethodDefinitionComputedName + extends MethodDefinitionComputedNameBase { + type: AST_NODE_TYPES.TSAbstractMethodDefinition; +} + +export interface TSAbstractMethodDefinitionNonComputedName + extends MethodDefinitionNonComputedNameBase { type: AST_NODE_TYPES.TSAbstractMethodDefinition; } @@ -1091,10 +1273,25 @@ export interface TSEnumDeclaration extends BaseNode { decorators?: Decorator[]; } -export interface TSEnumMember extends BaseNode { - type: AST_NODE_TYPES.TSEnumMember; - id: PropertyName; - initializer?: Expression; +/** + * this should only really happen in semantically invalid code (errors 1164 and 2452) + * + * VALID: + * enum Foo { ['a'] } + * + * INVALID: + * const x = 'a'; + * enum Foo { [x] } + * enum Bar { ['a' + 'b'] } + */ +export interface TSEnumMemberComputedName extends TSEnumMemberBase { + id: PropertyNameComputed; + computed: true; +} + +export interface TSEnumMemberNonComputedName extends TSEnumMemberBase { + id: PropertyNameNonComputed; + computed?: false; } export interface TSExportAssignment extends BaseNode { @@ -1190,18 +1387,15 @@ export interface TSMappedType extends BaseNode { typeAnnotation?: TypeNode; } -export interface TSMethodSignature extends BaseNode { - type: AST_NODE_TYPES.TSMethodSignature; - computed: boolean; - key: PropertyName; - params: Parameter[]; - optional?: boolean; - returnType?: TSTypeAnnotation; - readonly?: boolean; - typeParameters?: TSTypeParameterDeclaration; - accessibility?: Accessibility; - export?: boolean; - static?: boolean; +export interface TSMethodSignatureComputedName extends TSMethodSignatureBase { + key: PropertyNameComputed; + computed: true; +} + +export interface TSMethodSignatureNonComputedName + extends TSMethodSignatureBase { + key: PropertyNameNonComputed; + computed: false; } export interface TSModuleBlock extends BaseNode { @@ -1264,17 +1458,16 @@ export interface TSParenthesizedType extends BaseNode { typeAnnotation: TypeNode; } -export interface TSPropertySignature extends BaseNode { - type: AST_NODE_TYPES.TSPropertySignature; - optional?: boolean; - computed: boolean; - key: PropertyName; - typeAnnotation?: TSTypeAnnotation; - initializer?: Expression; - readonly?: boolean; - static?: boolean; - export?: boolean; - accessibility?: Accessibility; +export interface TSPropertySignatureComputedName + extends TSPropertySignatureBase { + key: PropertyNameComputed; + computed: true; +} + +export interface TSPropertySignatureNonComputedName + extends TSPropertySignatureBase { + key: PropertyNameNonComputed; + computed: false; } export interface TSPublicKeyword extends BaseNode { diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index cf18c1244e77..bf919d2eccac 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -616,6 +616,8 @@ tester.addFixturePatternConfig('typescript/basics', { 'class-with-readonly-property', 'object-with-escaped-properties', 'type-reference-comments', + // babel hard fails on computed string enum members, but TS doesn't + 'export-named-enum-computed-string', ], ignoreSourceType: [ /** diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 7454835c3ae1..90817f0b9614 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -1831,6 +1831,26 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-number.src 1`] = ` +Object { + "column": 4, + "index": 22, + "lineNumber": 2, + "message": "An enum member cannot have a numeric name.", +} +`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-string.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-named-enum-computed-var-ref.src 1`] = ` +Object { + "column": 4, + "index": 22, + "lineNumber": 2, + "message": "Computed property names are not allowed in enums.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-alias-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/export-type-class-declaration.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -1908,6 +1928,15 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/never-type-param.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/new-target-in-arrow-function-body.src 1`] = ` +Object { + "column": 16, + "index": 16, + "lineNumber": 1, + "message": "Meta-property 'new.target' is only allowed in the body of a function declaration, function expression, or constructor.", +} +`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/non-null-assertion-operator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/null-and-undefined-type-annotations.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 14b0a341b7a9..e53d5b3e9fb5 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -45600,7 +45600,7 @@ Object { } `; -exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-named-enum-computed-number.src 1`] = ` Object { "body": Array [ Object { @@ -45608,7 +45608,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 21, + "column": 15, "line": 1, }, "start": Object { @@ -45616,86 +45616,72 @@ Object { "line": 1, }, }, - "name": "TestAlias", + "name": "Foo", "range": Array [ 12, - 21, + 15, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 40, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { "column": 7, "line": 1, }, }, - "range": Array [ - 7, - 40, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "range": Array [ - 24, - 39, - ], - "type": "TSUnionType", - "types": Array [ - Object { + "members": Array [ + Object { + "computed": true, + "id": Object { "loc": Object { "end": Object { - "column": 30, - "line": 1, + "column": 6, + "line": 2, }, "start": Object { - "column": 24, - "line": 1, + "column": 5, + "line": 2, }, }, "range": Array [ + 23, 24, - 30, ], - "type": "TSStringKeyword", + "raw": "1", + "type": "Literal", + "value": 1, }, - Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, }, - "range": Array [ - 33, - 39, - ], - "type": "TSNumberKeyword", }, - ], - }, + "range": Array [ + 22, + 25, + ], + "type": "TSEnumMember", + }, + ], + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", }, "loc": Object { "end": Object { - "column": 40, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { "column": 0, @@ -45704,7 +45690,7 @@ Object { }, "range": Array [ 0, - 40, + 28, ], "source": null, "specifiers": Array [], @@ -45713,8 +45699,8 @@ Object { ], "loc": Object { "end": Object { - "column": 40, - "line": 1, + "column": 0, + "line": 4, }, "start": Object { "column": 0, @@ -45723,7 +45709,7 @@ Object { }, "range": Array [ 0, - 40, + 29, ], "sourceType": "module", "tokens": Array [ @@ -45760,13 +45746,13 @@ Object { 7, 11, ], - "type": "Identifier", - "value": "type", + "type": "Keyword", + "value": "enum", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 15, "line": 1, }, "start": Object { @@ -45776,107 +45762,125 @@ Object { }, "range": Array [ 12, - 21, + 15, ], "type": "Identifier", - "value": "TestAlias", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 17, "line": 1, }, "start": Object { - "column": 22, + "column": 16, "line": 1, }, }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, "range": Array [ 22, 23, ], "type": "Punctuator", - "value": "=", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 1, + "column": 6, + "line": 2, }, "start": Object { - "column": 24, - "line": 1, + "column": 5, + "line": 2, }, }, "range": Array [ + 23, 24, - 30, ], - "type": "Identifier", - "value": "string", + "type": "Numeric", + "value": "1", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 1, + "column": 7, + "line": 2, }, "start": Object { - "column": 31, - "line": 1, + "column": 6, + "line": 2, }, }, "range": Array [ - 31, - 32, + 24, + 25, ], "type": "Punctuator", - "value": "|", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 39, - "line": 1, + "column": 8, + "line": 2, }, "start": Object { - "column": 33, - "line": 1, + "column": 7, + "line": 2, }, }, "range": Array [ - 33, - 39, + 25, + 26, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 40, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 39, - "line": 1, + "column": 0, + "line": 3, }, }, "range": Array [ - 39, - 40, + 27, + 28, ], "type": "Punctuator", - "value": ";", + "value": "}", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/export-type-class-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-named-enum-computed-string.src 1`] = ` Object { "body": Array [ Object { @@ -45884,7 +45888,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { @@ -45892,16 +45896,16 @@ Object { "line": 1, }, }, - "name": "TestClassProps", + "name": "Foo", "range": Array [ 12, - 26, + 15, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 2, + "column": 1, "line": 3, }, "start": Object { @@ -45909,104 +45913,54 @@ Object { "line": 1, }, }, - "range": Array [ - 7, - 51, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 1, - "line": 3, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "name": "count", - "range": Array [ - 35, - 40, - ], - "type": "Identifier", - }, + "members": Array [ + Object { + "computed": true, + "id": Object { "loc": Object { "end": Object { - "column": 17, + "column": 10, "line": 2, }, "start": Object { - "column": 4, + "column": 5, "line": 2, }, }, "range": Array [ - 35, - 48, + 23, + 28, ], - "type": "TSPropertySignature", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 42, - 48, - ], - "type": "TSNumberKeyword", - }, + "raw": "'baz'", + "type": "Literal", + "value": "baz", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, }, }, - ], - "range": Array [ - 29, - 50, - ], - "type": "TSTypeLiteral", - }, + "range": Array [ + 22, + 29, + ], + "type": "TSEnumMember", + }, + ], + "range": Array [ + 7, + 32, + ], + "type": "TSEnumDeclaration", }, "loc": Object { "end": Object { - "column": 2, + "column": 1, "line": 3, }, "start": Object { @@ -46016,7 +45970,7 @@ Object { }, "range": Array [ 0, - 51, + 32, ], "source": null, "specifiers": Array [], @@ -46025,8 +45979,8 @@ Object { ], "loc": Object { "end": Object { - "column": 2, - "line": 3, + "column": 0, + "line": 4, }, "start": Object { "column": 0, @@ -46035,7 +45989,7 @@ Object { }, "range": Array [ 0, - 51, + 33, ], "sourceType": "module", "tokens": Array [ @@ -46072,13 +46026,13 @@ Object { 7, 11, ], - "type": "Identifier", - "value": "type", + "type": "Keyword", + "value": "enum", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 15, "line": 1, }, "start": Object { @@ -46088,87 +46042,87 @@ Object { }, "range": Array [ 12, - 26, + 15, ], "type": "Identifier", - "value": "TestClassProps", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 17, "line": 1, }, "start": Object { - "column": 27, + "column": 16, "line": 1, }, }, "range": Array [ - 27, - 28, + 16, + 17, ], "type": "Punctuator", - "value": "=", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 1, + "column": 5, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 29, - 30, + 22, + 23, ], "type": "Punctuator", - "value": "{", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 10, "line": 2, }, "start": Object { - "column": 4, + "column": 5, "line": 2, }, }, "range": Array [ - 35, - 40, + 23, + 28, ], - "type": "Identifier", - "value": "count", + "type": "String", + "value": "'baz'", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 11, "line": 2, }, "start": Object { - "column": 9, + "column": 10, "line": 2, }, }, "range": Array [ - 40, - 41, + 28, + 29, ], "type": "Punctuator", - "value": ":", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 12, "line": 2, }, "start": Object { @@ -46177,11 +46131,11 @@ Object { }, }, "range": Array [ - 42, - 48, + 29, + 30, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ",", }, Object { "loc": Object { @@ -46195,36 +46149,18 @@ Object { }, }, "range": Array [ - 49, - 50, + 31, + 32, ], "type": "Punctuator", "value": "}", }, - Object { - "loc": Object { - "end": Object { - "column": 2, - "line": 3, - }, - "start": Object { - "column": 1, - "line": 3, - }, - }, - "range": Array [ - 50, - 51, - ], - "type": "Punctuator", - "value": ";", - }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/export-type-function-declaration.src 1`] = ` +exports[`typescript fixtures/basics/export-named-enum-computed-var-ref.src 1`] = ` Object { "body": Array [ Object { @@ -46232,7 +46168,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 1, }, "start": Object { @@ -46240,138 +46176,71 @@ Object { "line": 1, }, }, - "name": "TestCallback", + "name": "Foo", "range": Array [ 12, - 24, + 15, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { "column": 7, "line": 1, }, }, - "range": Array [ - 7, - 47, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 46, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "params": Array [ - Object { + "members": Array [ + Object { + "computed": true, + "id": Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 6, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 5, + "line": 2, }, }, - "name": "a", + "name": "x", "range": Array [ - 28, - 37, + 23, + 24, ], "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "range": Array [ - 29, - 37, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 31, - "line": 1, - }, - }, - "range": Array [ - 31, - 37, - ], - "type": "TSNumberKeyword", - }, - }, }, - ], - "range": Array [ - 27, - 46, - ], - "returnType": Object { "loc": Object { "end": Object { - "column": 46, - "line": 1, + "column": 7, + "line": 2, }, "start": Object { - "column": 39, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 39, - 46, + 22, + 25, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 46, - "line": 1, - }, - "start": Object { - "column": 42, - "line": 1, - }, - }, - "range": Array [ - 42, - 46, - ], - "type": "TSVoidKeyword", - }, + "type": "TSEnumMember", }, - "type": "TSFunctionType", - }, + ], + "range": Array [ + 7, + 28, + ], + "type": "TSEnumDeclaration", }, "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { "column": 0, @@ -46380,7 +46249,7 @@ Object { }, "range": Array [ 0, - 47, + 28, ], "source": null, "specifiers": Array [], @@ -46389,8 +46258,8 @@ Object { ], "loc": Object { "end": Object { - "column": 47, - "line": 1, + "column": 0, + "line": 4, }, "start": Object { "column": 0, @@ -46399,7 +46268,7 @@ Object { }, "range": Array [ 0, - 47, + 29, ], "sourceType": "module", "tokens": Array [ @@ -46436,13 +46305,13 @@ Object { 7, 11, ], - "type": "Identifier", - "value": "type", + "type": "Keyword", + "value": "enum", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 1, }, "start": Object { @@ -46452,169 +46321,391 @@ Object { }, "range": Array [ 12, - 24, + 15, ], "type": "Identifier", - "value": "TestCallback", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 17, "line": 1, }, "start": Object { - "column": 25, + "column": 16, "line": 1, }, }, "range": Array [ - 25, - 26, + 16, + 17, ], "type": "Punctuator", - "value": "=", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 28, - "line": 1, + "column": 5, + "line": 2, }, "start": Object { - "column": 27, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 27, - 28, + 22, + 23, ], "type": "Punctuator", - "value": "(", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 29, - "line": 1, + "column": 6, + "line": 2, }, "start": Object { - "column": 28, - "line": 1, + "column": 5, + "line": 2, }, }, "range": Array [ - 28, - 29, + 23, + 24, ], "type": "Identifier", - "value": "a", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 1, + "column": 7, + "line": 2, }, "start": Object { - "column": 29, - "line": 1, + "column": 6, + "line": 2, }, }, "range": Array [ - 29, - 30, + 24, + 25, ], "type": "Punctuator", - "value": ":", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 1, + "column": 8, + "line": 2, }, "start": Object { - "column": 31, - "line": 1, + "column": 7, + "line": 2, }, }, "range": Array [ - 31, - 37, + 25, + 26, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": ",", }, Object { "loc": Object { "end": Object { - "column": 38, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 37, - "line": 1, + "column": 0, + "line": 3, }, }, "range": Array [ - 37, - 38, + 27, + 28, ], "type": "Punctuator", - "value": ")", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/export-type-alias-declaration.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "TestAlias", + "range": Array [ + 12, + 21, + ], + "type": "Identifier", }, - "start": Object { - "column": 39, - "line": 1, + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 40, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 39, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "TSNumberKeyword", + }, + ], }, }, - "range": Array [ - 39, - 41, - ], - "type": "Punctuator", - "value": "=>", - }, - Object { "loc": Object { "end": Object { - "column": 46, + "column": 40, "line": 1, }, "start": Object { - "column": 42, + "column": 0, "line": 1, }, }, "range": Array [ - 42, - 46, + 0, + 40, ], - "type": "Keyword", - "value": "void", + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", }, - Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, + ], + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 40, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, "start": Object { - "column": 46, + "column": 0, "line": 1, }, }, "range": Array [ - 46, - 47, + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 11, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 21, + ], + "type": "Identifier", + "value": "TestAlias", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, ], "type": "Punctuator", "value": ";", @@ -46624,231 +46715,134 @@ Object { } `; -exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` +exports[`typescript fixtures/basics/export-type-class-declaration.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 1, - }, - "start": Object { - "column": 4, - "line": 1, - }, + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, }, - "name": "obj", - "range": Array [ - 4, - 7, - ], - "type": "Identifier", }, - "init": Object { - "async": false, - "body": Object { - "body": Array [ - Object { - "argument": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "name": "a", - "range": Array [ - 45, - 46, - ], - "type": "Identifier", + "name": "TestClassProps", + "range": Array [ + 12, + 26, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 51, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, }, - "loc": Object { - "end": Object { - "column": 11, - "line": 2, - }, - "start": Object { - "column": 2, - "line": 2, - }, + "start": Object { + "column": 4, + "line": 2, }, - "range": Array [ - 38, - 47, - ], - "type": "ReturnStatement", }, - ], + "name": "count", + "range": Array [ + 35, + 40, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 1, - "line": 3, + "column": 17, + "line": 2, }, "start": Object { - "column": 34, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 34, - 49, + 35, + 48, ], - "type": "BlockStatement", - }, - "expression": false, - "generator": false, - "id": null, - "loc": Object { - "end": Object { - "column": 1, - "line": 3, - }, - "start": Object { - "column": 10, - "line": 1, - }, - }, - "params": Array [ - Object { + "type": "TSPropertySignature", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, - "line": 1, + "column": 17, + "line": 2, }, "start": Object { - "column": 23, - "line": 1, + "column": 9, + "line": 2, }, }, - "name": "a", "range": Array [ - 23, - 32, + 40, + 48, ], - "type": "Identifier", + "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, - "line": 1, + "column": 17, + "line": 2, }, "start": Object { - "column": 24, - "line": 1, + "column": 11, + "line": 2, }, }, "range": Array [ - 24, - 32, + 42, + 48, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 32, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, - }, - "range": Array [ - 26, - 32, - ], - "type": "TSStringKeyword", - }, - }, - }, - ], - "range": Array [ - 10, - 49, - ], - "type": "FunctionExpression", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 19, - "line": 1, + "type": "TSNumberKeyword", }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "name": Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 20, - 21, - ], - "type": "Identifier", - }, - "range": Array [ - 20, - 21, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 19, - 22, - ], - "type": "TSTypeParameterDeclaration", - }, - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 3, - }, - "start": Object { - "column": 4, - "line": 1, }, - }, + ], "range": Array [ - 4, - 49, + 29, + 50, ], - "type": "VariableDeclarator", + "type": "TSTypeLiteral", }, - ], - "kind": "var", + }, "loc": Object { "end": Object { "column": 2, @@ -46861,15 +46855,17 @@ Object { }, "range": Array [ 0, - 50, + 51, ], - "type": "VariableDeclaration", + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", }, ], "loc": Object { "end": Object { - "column": 0, - "line": 4, + "column": 2, + "line": 3, }, "start": Object { "column": 0, @@ -46880,12 +46876,12 @@ Object { 0, 51, ], - "sourceType": "script", + "sourceType": "module", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 6, "line": 1, }, "start": Object { @@ -46895,259 +46891,461 @@ Object { }, "range": Array [ 0, - 3, + 6, ], "type": "Keyword", - "value": "var", + "value": "export", }, Object { "loc": Object { "end": Object { - "column": 7, + "column": 11, "line": 1, }, "start": Object { - "column": 4, + "column": 7, "line": 1, }, }, "range": Array [ - 4, 7, + 11, ], "type": "Identifier", - "value": "obj", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 9, + "column": 26, "line": 1, }, "start": Object { - "column": 8, + "column": 12, "line": 1, }, }, "range": Array [ - 8, - 9, + 12, + 26, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "TestClassProps", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 28, "line": 1, }, "start": Object { - "column": 10, + "column": 27, "line": 1, }, }, "range": Array [ - 10, - 18, + 27, + 28, ], - "type": "Keyword", - "value": "function", + "type": "Punctuator", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 30, "line": 1, }, "start": Object { - "column": 19, + "column": 29, "line": 1, }, }, "range": Array [ - 19, - 20, + 29, + 30, ], "type": "Punctuator", - "value": "<", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 21, - "line": 1, + "column": 9, + "line": 2, }, "start": Object { - "column": 20, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 20, - 21, + 35, + 40, ], "type": "Identifier", - "value": "T", + "value": "count", }, Object { "loc": Object { "end": Object { - "column": 22, - "line": 1, + "column": 10, + "line": 2, }, "start": Object { - "column": 21, - "line": 1, + "column": 9, + "line": 2, }, }, "range": Array [ - 21, - 22, + 40, + 41, ], "type": "Punctuator", - "value": ">", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 1, + "column": 17, + "line": 2, }, "start": Object { - "column": 22, - "line": 1, + "column": 11, + "line": 2, }, }, "range": Array [ - 22, - 23, + 42, + 48, ], - "type": "Punctuator", - "value": "(", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 24, - "line": 1, + "column": 1, + "line": 3, }, "start": Object { - "column": 23, - "line": 1, + "column": 0, + "line": 3, }, }, "range": Array [ - 23, - 24, + 49, + 50, ], - "type": "Identifier", - "value": "a", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 1, + "column": 2, + "line": 3, }, "start": Object { - "column": 24, - "line": 1, + "column": 1, + "line": 3, }, }, "range": Array [ - 24, - 25, + 50, + 51, ], "type": "Punctuator", - "value": ":", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/export-type-function-declaration.src 1`] = ` +Object { + "body": Array [ Object { + "declaration": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "TestCallback", + "range": Array [ + 12, + 24, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 28, + 37, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 37, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 37, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 27, + 46, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 46, + ], + "type": "TSVoidKeyword", + }, + }, + "type": "TSFunctionType", + }, + }, "loc": Object { "end": Object { - "column": 32, + "column": 47, "line": 1, }, "start": Object { - "column": 26, + "column": 0, "line": 1, }, }, "range": Array [ - 26, - 32, + 0, + 47, ], - "type": "Identifier", - "value": "string", + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "module", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 33, + "column": 6, "line": 1, }, "start": Object { - "column": 32, + "column": 0, "line": 1, }, }, "range": Array [ - 32, - 33, + 0, + 6, ], - "type": "Punctuator", - "value": ")", + "type": "Keyword", + "value": "export", }, Object { "loc": Object { "end": Object { - "column": 35, + "column": 11, "line": 1, }, "start": Object { - "column": 34, + "column": 7, "line": 1, }, }, "range": Array [ - 34, - 35, + 7, + 11, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "type", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 2, + "column": 24, + "line": 1, }, "start": Object { - "column": 2, - "line": 2, + "column": 12, + "line": 1, }, }, "range": Array [ - 38, - 44, + 12, + 24, ], - "type": "Keyword", - "value": "return", + "type": "Identifier", + "value": "TestCallback", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, + "column": 26, + "line": 1, }, "start": Object { - "column": 9, - "line": 2, + "column": 25, + "line": 1, }, }, "range": Array [ - 45, - 46, + 25, + 26, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, ], "type": "Identifier", "value": "a", @@ -47155,53 +47353,107 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, - "line": 2, + "column": 30, + "line": 1, }, "start": Object { - "column": 10, - "line": 2, + "column": 29, + "line": 1, }, }, "range": Array [ - 46, - 47, + 29, + 30, ], "type": "Punctuator", - "value": ";", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 1, - "line": 3, + "column": 37, + "line": 1, }, "start": Object { - "column": 0, - "line": 3, + "column": 31, + "line": 1, }, }, "range": Array [ - 48, - 49, + 31, + 37, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, ], "type": "Punctuator", - "value": "}", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 2, - "line": 3, + "column": 41, + "line": 1, }, "start": Object { - "column": 1, - "line": 3, + "column": 39, + "line": 1, }, }, "range": Array [ - 49, - 50, + 39, + 41, + ], + "type": "Punctuator", + "value": "=>", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 46, + ], + "type": "Keyword", + "value": "void", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", "value": ";", @@ -47211,7 +47463,7 @@ Object { } `; -exports[`typescript fixtures/basics/function-anynomus-with-return-type.src 1`] = ` +exports[`typescript fixtures/basics/function-anonymus-with-type-parameters.src 1`] = ` Object { "body": Array [ Object { @@ -47238,20 +47490,56 @@ Object { "init": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 45, + 46, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 38, + 47, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { "column": 1, - "line": 2, + "line": 3, }, "start": Object { - "column": 28, + "column": 34, "line": 1, }, }, "range": Array [ - 28, - 31, + 34, + 49, ], "type": "BlockStatement", }, @@ -47261,38 +47549,18 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 2, + "line": 3, }, "start": Object { "column": 10, "line": 1, }, }, - "params": Array [], - "range": Array [ - 10, - 31, - ], - "returnType": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "range": Array [ - 21, - 27, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 27, + "column": 32, "line": 1, }, "start": Object { @@ -47300,37 +47568,130 @@ Object { "line": 1, }, }, + "name": "a", "range": Array [ 23, - 27, + 32, ], - "type": "TSVoidKeyword", - }, - }, - "type": "FunctionExpression", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 1, - }, - }, - "range": Array [ - 4, - 31, - ], - "type": "VariableDeclarator", - }, + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 32, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 10, + 49, + ], + "type": "FunctionExpression", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + "range": Array [ + 20, + 21, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 19, + 22, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 49, + ], + "type": "VariableDeclarator", + }, ], "kind": "var", "loc": Object { "end": Object { "column": 2, - "line": 2, + "line": 3, }, "start": Object { "column": 0, @@ -47339,7 +47700,7 @@ Object { }, "range": Array [ 0, - 32, + 50, ], "type": "VariableDeclaration", }, @@ -47347,7 +47708,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 3, + "line": 4, }, "start": Object { "column": 0, @@ -47356,7 +47717,7 @@ Object { }, "range": Array [ 0, - 33, + 51, ], "sourceType": "script", "tokens": Array [ @@ -47448,7 +47809,7 @@ Object { 20, ], "type": "Punctuator", - "value": "(", + "value": "<", }, Object { "loc": Object { @@ -47465,8 +47826,8 @@ Object { 20, 21, ], - "type": "Punctuator", - "value": ")", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { @@ -47484,12 +47845,30 @@ Object { 22, ], "type": "Punctuator", - "value": ":", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 27, + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, "line": 1, }, "start": Object { @@ -47499,25 +47878,79 @@ Object { }, "range": Array [ 23, - 27, + 24, ], - "type": "Keyword", - "value": "void", + "type": "Identifier", + "value": "a", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 25, "line": 1, }, "start": Object { - "column": 28, + "column": 24, "line": 1, }, }, "range": Array [ - 28, - 29, + 24, + 25, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, ], "type": "Punctuator", "value": "{", @@ -47525,111 +47958,173 @@ Object { Object { "loc": Object { "end": Object { - "column": 1, + "column": 8, "line": 2, }, "start": Object { - "column": 0, + "column": 2, "line": 2, }, }, "range": Array [ - 30, - 31, + 38, + 44, ], - "type": "Punctuator", - "value": "}", + "type": "Keyword", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 2, + "column": 10, "line": 2, }, "start": Object { - "column": 1, + "column": 9, "line": 2, }, }, "range": Array [ - 31, - 32, + 45, + 46, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", "value": ";", }, - ], + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 3, + }, + "start": Object { + "column": 1, + "line": 3, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": ";", + }, + ], "type": "Program", } `; -exports[`typescript fixtures/basics/function-overloads.src 1`] = ` +exports[`typescript fixtures/basics/function-anynomus-with-return-type.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "name": "f", - "range": Array [ - 16, - 17, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, - }, - "params": Array [ - Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 27, + "column": 7, "line": 1, }, "start": Object { - "column": 18, + "column": 4, "line": 1, }, }, - "name": "x", + "name": "obj", "range": Array [ - 18, - 27, + 4, + 7, ], "type": "Identifier", - "typeAnnotation": Object { + }, + "init": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 31, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 10, + 31, + ], + "returnType": Object { "loc": Object { "end": Object { "column": 27, "line": 1, }, "start": Object { - "column": 19, + "column": 21, "line": 1, }, }, "range": Array [ - 19, + 21, 27, ], "type": "TSTypeAnnotation", @@ -47640,62 +48135,74 @@ Object { "line": 1, }, "start": Object { - "column": 21, + "column": 23, "line": 1, }, }, "range": Array [ - 21, + 23, 27, ], - "type": "TSNumberKeyword", + "type": "TSVoidKeyword", }, }, + "type": "FunctionExpression", }, - ], - "range": Array [ - 7, - 37, - ], - "returnType": Object { "loc": Object { "end": Object { - "column": 36, - "line": 1, + "column": 1, + "line": 2, }, "start": Object { - "column": 28, + "column": 4, "line": 1, }, }, "range": Array [ - 28, - 36, + 4, + 31, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "range": Array [ - 30, - 36, - ], - "type": "TSNumberKeyword", - }, + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, }, - "type": "TSDeclareFunction", }, + "range": Array [ + 0, + 32, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "script", + "tokens": Array [ + Object { "loc": Object { "end": Object { - "column": 37, + "column": 3, "line": 1, }, "start": Object { @@ -47705,133 +48212,465 @@ Object { }, "range": Array [ 0, - 37, + 3, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "Keyword", + "value": "var", }, Object { - "declaration": Object { - "async": false, - "expression": false, - "generator": false, - "id": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "f", - "range": Array [ - 54, - 55, - ], - "type": "Identifier", + "loc": Object { + "end": Object { + "column": 7, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 37, - "line": 2, - }, - "start": Object { - "column": 7, - "line": 2, - }, + "start": Object { + "column": 4, + "line": 1, }, - "params": Array [ + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "obj", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 18, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 27, + ], + "type": "Keyword", + "value": "void", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 2, + }, + "start": Object { + "column": 1, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/function-overloads.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "f", + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "params": Array [ Object { "loc": Object { "end": Object { "column": 27, - "line": 2, + "line": 1, }, "start": Object { "column": 18, - "line": 2, + "line": 1, }, }, "name": "x", "range": Array [ - 56, - 65, + 18, + 27, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { "column": 27, - "line": 2, + "line": 1, }, "start": Object { "column": 19, - "line": 2, + "line": 1, }, }, "range": Array [ - 57, - 65, + 19, + 27, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { "column": 27, - "line": 2, + "line": 1, }, "start": Object { "column": 21, - "line": 2, + "line": 1, }, }, "range": Array [ - 59, - 65, + 21, + 27, ], - "type": "TSStringKeyword", + "type": "TSNumberKeyword", }, }, }, ], "range": Array [ - 45, - 75, + 7, + 37, ], "returnType": Object { "loc": Object { "end": Object { "column": 36, - "line": 2, + "line": 1, }, "start": Object { "column": 28, - "line": 2, + "line": 1, }, }, "range": Array [ - 66, - 74, + 28, + 36, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { "column": 36, - "line": 2, + "line": 1, }, "start": Object { "column": 30, - "line": 2, + "line": 1, }, }, "range": Array [ - 68, - 74, + 30, + 36, + ], + "type": "TSNumberKeyword", + }, + }, + "type": "TSDeclareFunction", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + Object { + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "f", + "range": Array [ + 54, + 55, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "name": "x", + "range": Array [ + 56, + 65, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 57, + 65, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "range": Array [ + 59, + 65, + ], + "type": "TSStringKeyword", + }, + }, + }, + ], + "range": Array [ + 45, + 75, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 66, + 74, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 68, + 74, ], "type": "TSStringKeyword", }, @@ -65412,326 +66251,837 @@ Object { "column": 0, "line": 10, }, - }, - "range": Array [ - 112, - 118, + }, + "range": Array [ + 112, + 118, + ], + "type": "Keyword", + "value": "import", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 10, + }, + "start": Object { + "column": 7, + "line": 10, + }, + }, + "range": Array [ + 119, + 120, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 11, + }, + "start": Object { + "column": 2, + "line": 11, + }, + }, + "range": Array [ + 123, + 126, + ], + "type": "Identifier", + "value": "get", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 11, + }, + "start": Object { + "column": 5, + "line": 11, + }, + }, + "range": Array [ + 126, + 127, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 12, + }, + "start": Object { + "column": 2, + "line": 12, + }, + }, + "range": Array [ + 130, + 133, + ], + "type": "Identifier", + "value": "set", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 12, + }, + "start": Object { + "column": 5, + "line": 12, + }, + }, + "range": Array [ + 133, + 134, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 13, + }, + "start": Object { + "column": 2, + "line": 13, + }, + }, + "range": Array [ + 137, + 143, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 13, + }, + "start": Object { + "column": 8, + "line": 13, + }, + }, + "range": Array [ + 143, + 144, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 14, + }, + "start": Object { + "column": 2, + "line": 14, + }, + }, + "range": Array [ + 147, + 151, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 14, + }, + "start": Object { + "column": 6, + "line": 14, + }, + }, + "range": Array [ + 151, + 152, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 15, + }, + "start": Object { + "column": 2, + "line": 15, + }, + }, + "range": Array [ + 155, + 160, + ], + "type": "Identifier", + "value": "async", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 15, + }, + "start": Object { + "column": 7, + "line": 15, + }, + }, + "range": Array [ + 160, + 161, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 16, + }, + "start": Object { + "column": 2, + "line": 16, + }, + }, + "range": Array [ + 164, + 166, + ], + "type": "Identifier", + "value": "is", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 16, + }, + "start": Object { + "column": 4, + "line": 16, + }, + }, + "range": Array [ + 166, + 167, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 17, + }, + "start": Object { + "column": 0, + "line": 17, + }, + }, + "range": Array [ + 168, + 169, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 17, + }, + "start": Object { + "column": 2, + "line": 17, + }, + }, + "range": Array [ + 170, + 174, + ], + "type": "Identifier", + "value": "from", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 17, + }, + "start": Object { + "column": 7, + "line": 17, + }, + }, + "range": Array [ + 175, + 188, + ], + "type": "String", + "value": "'fake-module'", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 17, + }, + "start": Object { + "column": 20, + "line": 17, + }, + }, + "range": Array [ + 188, + 189, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/nested-type-arguments.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "nestedArray", + "range": Array [ + 4, + 44, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 44, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 44, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 17, + 22, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 43, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 23, + 28, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 42, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 29, + 34, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 41, + ], + "type": "TSStringKeyword", + }, + ], + "range": Array [ + 34, + 42, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "range": Array [ + 28, + 43, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "range": Array [ + 22, + 44, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 44, + ], + "type": "VariableDeclarator", + }, ], - "type": "Keyword", - "value": "import", - }, - Object { + "kind": "var", "loc": Object { "end": Object { - "column": 8, - "line": 10, + "column": 44, + "line": 1, }, "start": Object { - "column": 7, - "line": 10, + "column": 0, + "line": 1, }, }, "range": Array [ - 119, - 120, + 0, + 44, ], - "type": "Punctuator", - "value": "{", + "type": "VariableDeclaration", }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 11, - }, - "start": Object { - "column": 2, - "line": 11, - }, - }, - "range": Array [ - 123, - 126, - ], - "type": "Identifier", - "value": "get", + ], + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 44, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, - "line": 11, + "column": 3, + "line": 1, }, "start": Object { - "column": 5, - "line": 11, + "column": 0, + "line": 1, }, }, "range": Array [ - 126, - 127, + 0, + 3, ], - "type": "Punctuator", - "value": ",", + "type": "Keyword", + "value": "var", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 12, + "column": 15, + "line": 1, }, "start": Object { - "column": 2, - "line": 12, + "column": 4, + "line": 1, }, }, "range": Array [ - 130, - 133, + 4, + 15, ], "type": "Identifier", - "value": "set", + "value": "nestedArray", }, Object { "loc": Object { "end": Object { - "column": 6, - "line": 12, + "column": 16, + "line": 1, }, "start": Object { - "column": 5, - "line": 12, + "column": 15, + "line": 1, }, }, "range": Array [ - 133, - 134, + 15, + 16, ], "type": "Punctuator", - "value": ",", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 13, + "column": 22, + "line": 1, }, "start": Object { - "column": 2, - "line": 13, + "column": 17, + "line": 1, }, }, "range": Array [ - 137, - 143, + 17, + 22, ], "type": "Identifier", - "value": "module", + "value": "Array", }, Object { "loc": Object { "end": Object { - "column": 9, - "line": 13, + "column": 23, + "line": 1, }, "start": Object { - "column": 8, - "line": 13, + "column": 22, + "line": 1, }, }, "range": Array [ - 143, - 144, + 22, + 23, ], "type": "Punctuator", - "value": ",", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 6, - "line": 14, + "column": 28, + "line": 1, }, "start": Object { - "column": 2, - "line": 14, + "column": 23, + "line": 1, }, }, "range": Array [ - 147, - 151, + 23, + 28, ], "type": "Identifier", - "value": "type", + "value": "Array", }, Object { "loc": Object { "end": Object { - "column": 7, - "line": 14, + "column": 29, + "line": 1, }, "start": Object { - "column": 6, - "line": 14, + "column": 28, + "line": 1, }, }, "range": Array [ - 151, - 152, + 28, + 29, ], "type": "Punctuator", - "value": ",", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 7, - "line": 15, + "column": 34, + "line": 1, }, "start": Object { - "column": 2, - "line": 15, + "column": 29, + "line": 1, }, }, "range": Array [ - 155, - 160, + 29, + 34, ], "type": "Identifier", - "value": "async", + "value": "Array", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 15, + "column": 35, + "line": 1, }, "start": Object { - "column": 7, - "line": 15, + "column": 34, + "line": 1, }, }, "range": Array [ - 160, - 161, + 34, + 35, ], "type": "Punctuator", - "value": ",", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 4, - "line": 16, + "column": 41, + "line": 1, }, "start": Object { - "column": 2, - "line": 16, + "column": 35, + "line": 1, }, }, "range": Array [ - 164, - 166, + 35, + 41, ], "type": "Identifier", - "value": "is", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 16, - }, - "start": Object { - "column": 4, - "line": 16, - }, - }, - "range": Array [ - 166, - 167, - ], - "type": "Punctuator", - "value": ",", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 1, - "line": 17, + "column": 42, + "line": 1, }, "start": Object { - "column": 0, - "line": 17, + "column": 41, + "line": 1, }, }, "range": Array [ - 168, - 169, + 41, + 42, ], "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 17, - }, - "start": Object { - "column": 2, - "line": 17, - }, - }, - "range": Array [ - 170, - 174, - ], - "type": "Identifier", - "value": "from", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 20, - "line": 17, + "column": 43, + "line": 1, }, - "start": Object { - "column": 7, - "line": 17, + "start": Object { + "column": 42, + "line": 1, }, }, "range": Array [ - 175, - 188, + 42, + 43, ], - "type": "String", - "value": "'fake-module'", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 21, - "line": 17, + "column": 44, + "line": 1, }, "start": Object { - "column": 20, - "line": 17, + "column": 43, + "line": 1, }, }, "range": Array [ - 188, - 189, + 43, + 44, ], "type": "Punctuator", - "value": ";", + "value": ">", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/nested-type-arguments.src 1`] = ` +exports[`typescript fixtures/basics/never-type-param.src 1`] = ` Object { "body": Array [ Object { @@ -65740,78 +67090,78 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 44, + "column": 17, "line": 1, }, "start": Object { - "column": 4, + "column": 6, "line": 1, }, }, - "name": "nestedArray", + "name": "x", "range": Array [ - 4, - 44, + 6, + 17, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 44, + "column": 17, "line": 1, }, "start": Object { - "column": 15, + "column": 7, "line": 1, }, }, "range": Array [ - 15, - 44, + 7, + 17, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 44, + "column": 17, "line": 1, }, "start": Object { - "column": 17, + "column": 9, "line": 1, }, }, "range": Array [ + 9, 17, - 44, ], "type": "TSTypeReference", "typeName": Object { "loc": Object { "end": Object { - "column": 22, + "column": 10, "line": 1, }, "start": Object { - "column": 17, + "column": 9, "line": 1, }, }, - "name": "Array", + "name": "X", "range": Array [ - 17, - 22, + 9, + 10, ], "type": "Identifier", }, "typeParameters": Object { "loc": Object { "end": Object { - "column": 44, + "column": 17, "line": 1, }, "start": Object { - "column": 22, + "column": 10, "line": 1, }, }, @@ -65819,178 +67169,197 @@ Object { Object { "loc": Object { "end": Object { - "column": 43, + "column": 16, "line": 1, }, "start": Object { - "column": 23, + "column": 11, "line": 1, }, }, "range": Array [ - 23, - 43, + 11, + 16, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "name": "Array", - "range": Array [ - 23, - 28, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 43, - "line": 1, - }, - "start": Object { - "column": 28, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "range": Array [ - 29, - 42, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 34, - "line": 1, - }, - "start": Object { - "column": 29, - "line": 1, - }, - }, - "name": "Array", - "range": Array [ - 29, - 34, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 42, - "line": 1, - }, - "start": Object { - "column": 34, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "range": Array [ - 35, - 41, - ], - "type": "TSStringKeyword", - }, - ], - "range": Array [ - 34, - 42, - ], - "type": "TSTypeParameterInstantiation", - }, - }, - ], - "range": Array [ - 28, - 43, - ], - "type": "TSTypeParameterInstantiation", - }, + "type": "TSNeverKeyword", }, ], "range": Array [ - 22, - 44, + 10, + 17, ], "type": "TSTypeParameterInstantiation", }, }, }, }, - "init": null, + "init": null, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 17, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "VariableDeclaration", + }, + Object { + "expression": Object { + "arguments": Array [], + "callee": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "name": "Observable", + "range": Array [ + 19, + 29, + ], + "type": "Identifier", + }, + "optional": false, + "property": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "empty", + "range": Array [ + 30, + 35, + ], + "type": "Identifier", + }, + "range": Array [ + 19, + 35, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "optional": false, + "range": Array [ + 19, + 44, + ], + "type": "CallExpression", + "typeParameters": Object { "loc": Object { "end": Object { - "column": 44, - "line": 1, + "column": 23, + "line": 2, }, "start": Object { - "column": 4, - "line": 1, + "column": 16, + "line": 2, }, }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 36, + 41, + ], + "type": "TSNeverKeyword", + }, + ], "range": Array [ - 4, - 44, + 35, + 42, ], - "type": "VariableDeclarator", + "type": "TSTypeParameterInstantiation", }, - ], - "kind": "var", + }, "loc": Object { "end": Object { - "column": 44, - "line": 1, + "column": 26, + "line": 2, }, "start": Object { "column": 0, - "line": 1, + "line": 2, }, }, "range": Array [ - 0, - 44, + 19, + 45, ], - "type": "VariableDeclaration", + "type": "ExpressionStatement", }, ], "loc": Object { "end": Object { - "column": 44, - "line": 1, + "column": 0, + "line": 3, }, "start": Object { "column": 0, @@ -65999,14 +67368,14 @@ Object { }, "range": Array [ 0, - 44, + 46, ], "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 3, + "column": 5, "line": 1, }, "start": Object { @@ -66016,43 +67385,43 @@ Object { }, "range": Array [ 0, - 3, + 5, ], "type": "Keyword", - "value": "var", + "value": "const", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 7, "line": 1, }, "start": Object { - "column": 4, + "column": 6, "line": 1, }, }, "range": Array [ - 4, - 15, + 6, + 7, ], "type": "Identifier", - "value": "nestedArray", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 8, "line": 1, }, "start": Object { - "column": 15, + "column": 7, "line": 1, }, }, "range": Array [ - 15, - 16, + 7, + 8, ], "type": "Punctuator", "value": ":", @@ -66060,35 +67429,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 22, + "column": 10, "line": 1, }, "start": Object { - "column": 17, + "column": 9, "line": 1, }, }, "range": Array [ - 17, - 22, + 9, + 10, ], "type": "Identifier", - "value": "Array", + "value": "X", }, Object { "loc": Object { "end": Object { - "column": 23, + "column": 11, "line": 1, }, "start": Object { - "column": 22, + "column": 10, "line": 1, }, }, "range": Array [ - 22, - 23, + 10, + 11, ], "type": "Punctuator", "value": "<", @@ -66096,71 +67465,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 28, + "column": 16, "line": 1, }, "start": Object { - "column": 23, + "column": 11, "line": 1, }, }, "range": Array [ - 23, - 28, + 11, + 16, ], "type": "Identifier", - "value": "Array", + "value": "never", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 17, "line": 1, }, "start": Object { - "column": 28, + "column": 16, "line": 1, }, }, "range": Array [ - 28, - 29, + 16, + 17, ], "type": "Punctuator", - "value": "<", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 34, + "column": 18, "line": 1, }, "start": Object { - "column": 29, + "column": 17, "line": 1, }, }, "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 19, 29, - 34, ], "type": "Identifier", - "value": "Array", + "value": "Observable", }, Object { "loc": Object { "end": Object { - "column": 35, - "line": 1, + "column": 11, + "line": 2, }, "start": Object { - "column": 34, - "line": 1, + "column": 10, + "line": 2, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 30, + 35, + ], + "type": "Identifier", + "value": "empty", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, }, }, "range": Array [ - 34, 35, + 36, ], "type": "Punctuator", "value": "<", @@ -66168,81 +67591,99 @@ Object { Object { "loc": Object { "end": Object { - "column": 41, - "line": 1, + "column": 22, + "line": 2, }, "start": Object { - "column": 35, - "line": 1, + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 36, + 41, + ], + "type": "Identifier", + "value": "never", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, }, }, "range": Array [ - 35, 41, + 42, ], - "type": "Identifier", - "value": "string", + "type": "Punctuator", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 42, - "line": 1, + "column": 24, + "line": 2, }, "start": Object { - "column": 41, - "line": 1, + "column": 23, + "line": 2, }, }, "range": Array [ - 41, 42, + 43, ], "type": "Punctuator", - "value": ">", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 43, - "line": 1, + "column": 25, + "line": 2, }, "start": Object { - "column": 42, - "line": 1, + "column": 24, + "line": 2, }, }, "range": Array [ - 42, 43, + 44, ], "type": "Punctuator", - "value": ">", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 1, + "column": 26, + "line": 2, }, "start": Object { - "column": 43, - "line": 1, + "column": 25, + "line": 2, }, }, "range": Array [ - 43, 44, + 45, ], "type": "Punctuator", - "value": ">", + "value": ";", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/never-type-param.src 1`] = ` +exports[`typescript fixtures/basics/new-target-in-arrow-function-body.src 1`] = ` Object { "body": Array [ Object { @@ -66251,7 +67692,7 @@ Object { "id": Object { "loc": Object { "end": Object { - "column": 17, + "column": 7, "line": 1, }, "start": Object { @@ -66259,268 +67700,127 @@ Object { "line": 1, }, }, - "name": "x", + "name": "b", "range": Array [ 6, - 17, + 7, ], "type": "Identifier", - "typeAnnotation": Object { + }, + "init": Object { + "async": false, + "body": Object { "loc": Object { "end": Object { - "column": 17, + "column": 26, "line": 1, }, "start": Object { - "column": 7, + "column": 16, "line": 1, }, }, - "range": Array [ - 7, - 17, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "meta": Object { "loc": Object { "end": Object { - "column": 17, + "column": 19, "line": 1, }, "start": Object { - "column": 9, + "column": 16, "line": 1, }, }, + "name": "new", "range": Array [ - 9, - 17, + 16, + 19, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, }, - "name": "X", - "range": Array [ - 9, - 10, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 10, - "line": 1, - }, + "start": Object { + "column": 20, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 16, - ], - "type": "TSNeverKeyword", - }, - ], - "range": Array [ - 10, - 17, - ], - "type": "TSTypeParameterInstantiation", }, + "name": "target", + "range": Array [ + 20, + 26, + ], + "type": "Identifier", }, + "range": Array [ + 16, + 26, + ], + "type": "MetaProperty", }, - }, - "init": null, - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 6, - "line": 1, - }, - }, - "range": Array [ - 6, - 17, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "const", - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 18, - ], - "type": "VariableDeclaration", - }, - Object { - "expression": Object { - "arguments": Array [], - "callee": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, - }, - }, - "name": "Observable", - "range": Array [ - 19, - 29, - ], - "type": "Identifier", - }, - "optional": false, - "property": Object { + "expression": true, + "generator": false, + "id": null, "loc": Object { "end": Object { - "column": 16, - "line": 2, + "column": 26, + "line": 1, }, "start": Object { - "column": 11, - "line": 2, + "column": 10, + "line": 1, }, }, - "name": "empty", + "params": Array [], "range": Array [ - 30, - 35, - ], - "type": "Identifier", - }, - "range": Array [ - 19, - 35, - ], - "type": "MemberExpression", - }, - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, - }, - }, - "optional": false, - "range": Array [ - 19, - 44, - ], - "type": "CallExpression", - "typeParameters": Object { + 10, + 26, + ], + "type": "ArrowFunctionExpression", + }, "loc": Object { "end": Object { - "column": 23, - "line": 2, + "column": 26, + "line": 1, }, "start": Object { - "column": 16, - "line": 2, + "column": 6, + "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 36, - 41, - ], - "type": "TSNeverKeyword", - }, - ], "range": Array [ - 35, - 42, + 6, + 26, ], - "type": "TSTypeParameterInstantiation", + "type": "VariableDeclarator", }, - }, + ], + "kind": "const", "loc": Object { "end": Object { - "column": 26, - "line": 2, + "column": 27, + "line": 1, }, "start": Object { "column": 0, - "line": 2, + "line": 1, }, }, "range": Array [ - 19, - 45, + 0, + 27, ], - "type": "ExpressionStatement", + "type": "VariableDeclaration", }, ], "loc": Object { "end": Object { "column": 0, - "line": 3, + "line": 2, }, "start": Object { "column": 0, @@ -66529,7 +67829,7 @@ Object { }, "range": Array [ 0, - 46, + 28, ], "sourceType": "script", "tokens": Array [ @@ -66567,43 +67867,25 @@ Object { 7, ], "type": "Identifier", - "value": "x", + "value": "b", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 9, "line": 1, }, "start": Object { - "column": 7, + "column": 8, "line": 1, }, }, "range": Array [ - 7, 8, - ], - "type": "Punctuator", - "value": ":", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "range": Array [ 9, - 10, ], - "type": "Identifier", - "value": "X", + "type": "Punctuator", + "value": "=", }, Object { "loc": Object { @@ -66621,12 +67903,12 @@ Object { 11, ], "type": "Punctuator", - "value": "<", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 12, "line": 1, }, "start": Object { @@ -66636,79 +67918,61 @@ Object { }, "range": Array [ 11, - 16, + 12, ], - "type": "Identifier", - "value": "never", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 15, "line": 1, }, "start": Object { - "column": 16, + "column": 13, "line": 1, }, }, "range": Array [ - 16, - 17, + 13, + 15, ], "type": "Punctuator", - "value": ">", + "value": "=>", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 19, "line": 1, }, "start": Object { - "column": 17, + "column": 16, "line": 1, }, }, "range": Array [ - 17, - 18, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, - }, - }, - "range": Array [ + 16, 19, - 29, ], - "type": "Identifier", - "value": "Observable", + "type": "Keyword", + "value": "new", }, Object { "loc": Object { "end": Object { - "column": 11, - "line": 2, + "column": 20, + "line": 1, }, "start": Object { - "column": 10, - "line": 2, + "column": 19, + "line": 1, }, }, "range": Array [ - 29, - 30, + 19, + 20, ], "type": "Punctuator", "value": ".", @@ -66716,125 +67980,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 30, - 35, - ], - "type": "Identifier", - "value": "empty", - }, - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 35, - 36, - ], - "type": "Punctuator", - "value": "<", - }, - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 2, + "column": 26, + "line": 1, }, "start": Object { - "column": 17, - "line": 2, + "column": 20, + "line": 1, }, }, "range": Array [ - 36, - 41, + 20, + 26, ], "type": "Identifier", - "value": "never", + "value": "target", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, - }, - "range": Array [ - 41, - 42, - ], - "type": "Punctuator", - "value": ">", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 2, - }, - "start": Object { - "column": 23, - "line": 2, - }, - }, - "range": Array [ - 42, - 43, - ], - "type": "Punctuator", - "value": "(", - }, - Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 2, + "column": 27, + "line": 1, }, "start": Object { - "column": 24, - "line": 2, - }, - }, - "range": Array [ - 43, - 44, - ], - "type": "Punctuator", - "value": ")", - }, - Object { - "loc": Object { - "end": Object { "column": 26, - "line": 2, - }, - "start": Object { - "column": 25, - "line": 2, + "line": 1, }, }, "range": Array [ - 44, - 45, + 26, + 27, ], "type": "Punctuator", "value": ";", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy