diff --git a/.gitignore b/.gitignore index 5f01791..34a9c5a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ _test.js .vscode yarn.lock .eslint-release-info.json +.idea diff --git a/README.md b/README.md index f2c4442..97b92d1 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The following additional configuration options are available by specifying them We will always endeavor to support the latest stable version of TypeScript. -The version of TypeScript currently supported by this parser is `~3.1.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. +The version of TypeScript currently supported by this parser is `~3.2.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript. If you use a non-supported version of TypeScript, the parser will log a warning to the console. diff --git a/analyze-scope.js b/analyze-scope.js index a542a22..5505973 100644 --- a/analyze-scope.js +++ b/analyze-scope.js @@ -65,6 +65,13 @@ class PatternVisitor extends OriginalPatternVisitor { this.rightHandNodes.push(node.typeAnnotation); } } + + RestElement(node) { + super.RestElement(node); + if (node.typeAnnotation) { + this.rightHandNodes.push(node.typeAnnotation); + } + } } class Referencer extends OriginalReferencer { @@ -120,7 +127,7 @@ class Referencer extends OriginalReferencer { const { defs, identifiers } = upperScope.set.get(id.name); for (let i = 0; i < defs.length; ++i) { const def = defs[i]; - if (def.type === "FunctionName" && def.node.type === "TSEmptyBodyFunctionDeclaration") { + if (def.type === "FunctionName" && def.node.type === "TSDeclareFunction") { defs.splice(i, 1); identifiers.splice(i, 1); break; @@ -239,28 +246,9 @@ class Referencer extends OriginalReferencer { super.MethodDefinition(node); } - /** - * Override. - * Don't make variable if `kind === "type"`. - * It doesn't declare variables but declare types. - * @param {VariableDeclaration} node The VariableDeclaration node to visit. - * @returns {void} - */ - VariableDeclaration(node) { - if (node.kind !== "type") { - super.VariableDeclaration(node); - return; - } - - // To detect typeof. - this.typeMode = true; - this.visitChildren(node); - this.typeMode = false; - } - /** * Don't create the reference object for the key if not computed. - * @param {TSEmptyBodyFunctionDeclaration} node The TSEmptyBodyFunctionDeclaration node to visit. + * @param {ClassProperty} node The ClassProperty node to visit. * @returns {void} */ ClassProperty(node) { @@ -311,23 +299,25 @@ class Referencer extends OriginalReferencer { /** * Define the variable of this function declaration only once. * Because to avoid confusion of `no-redeclare` rule by overloading. - * @param {TSEmptyBodyFunctionDeclaration} node The TSEmptyBodyFunctionDeclaration node to visit. + * @param {TSDeclareFunction} node The TSDeclareFunction node to visit. * @returns {void} */ - TSEmptyBodyFunctionDeclaration(node) { + TSDeclareFunction(node) { const upperTypeMode = this.typeMode; const scope = this.currentScope(); const { id, typeParameters, params, returnType } = node; // Ignore this if other overloadings have already existed. - const variable = scope.set.get(id.name); - const defs = variable && variable.defs; - const existed = defs && defs.some(d => d.type === "FunctionName"); - if (!existed) { - scope.__define( - id, - new Definition("FunctionName", id, node, null, null, null) - ); + if (id) { + const variable = scope.set.get(id.name); + const defs = variable && variable.defs; + const existed = defs && defs.some(d => d.type === "FunctionName"); + if (!existed) { + scope.__define( + id, + new Definition("FunctionName", id, node, null, null, null) + ); + } } // Find `typeof` expressions. @@ -337,9 +327,6 @@ class Referencer extends OriginalReferencer { this.visit(returnType); this.typeMode = upperTypeMode; } - TSEmptyBodyDeclareFunction(node) { - this.TSEmptyBodyFunctionDeclaration(node); - } /** * Create reference objects for the references in parameters and return type. @@ -364,43 +351,79 @@ class Referencer extends OriginalReferencer { * @returns {void} */ TSInterfaceDeclaration(node) { + this.visitTypeNodes(node); + } + + /** + * Don't make variable because it declares only types. + * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. + * @param {TSClassImplements} node The TSClassImplements node to visit. + * @returns {void} + */ + TSClassImplements(node) { + this.visitTypeNodes(node); + } + + /** + * Don't make variable because it declares only types. + * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. + * @param {TSIndexSignature} node The TSIndexSignature node to visit. + * @returns {void} + */ + TSIndexSignature(node) { + this.visitTypeNodes(node); + } + + /** + * Visit type assertion. + * @param {TSTypeAssertion} node The TSTypeAssertion node to visit. + * @returns {void} + */ + TSTypeAssertion(node) { if (this.typeMode) { - this.visitChildren(node); + this.visit(node.typeAnnotation); } else { this.typeMode = true; - this.visitChildren(node); + this.visit(node.typeAnnotation); this.typeMode = false; } + + this.visit(node.expression); } /** - * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSTypeAnnotation} node The TSTypeAnnotation node to visit. + * Visit as expression. + * @param {TSAsExpression} node The TSAsExpression node to visit. * @returns {void} */ - TSTypeAnnotation(node) { + TSAsExpression(node) { + this.visit(node.expression); + if (this.typeMode) { - this.visitChildren(node); + this.visit(node.typeAnnotation); } else { this.typeMode = true; - this.visitChildren(node); + this.visit(node.typeAnnotation); this.typeMode = false; } } + /** + * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. + * @param {TSTypeAnnotation} node The TSTypeAnnotation node to visit. + * @returns {void} + */ + TSTypeAnnotation(node) { + this.visitTypeNodes(node); + } + /** * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param {TSTypeParameterDeclaration} node The TSTypeParameterDeclaration node to visit. * @returns {void} */ TSTypeParameterDeclaration(node) { - if (this.typeMode) { - this.visitChildren(node); - } else { - this.typeMode = true; - this.visitChildren(node); - this.typeMode = false; - } + this.visitTypeNodes(node); } /** @@ -418,9 +441,113 @@ class Referencer extends OriginalReferencer { } } + /** + * @param {TSTypeParameter} node The TSTypeParameter node to visit. + * @returns {void} + */ + TSTypeParameter(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSInferType} node The TSInferType node to visit. + * @returns {void} + */ + TSInferType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSTypeReference} node The TSTypeReference node to visit. + * @returns {void} + */ + TSTypeReference(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSTypeLiteral} node The TSTypeLiteral node to visit. + * @returns {void} + */ + TSTypeLiteral(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSLiteralType} node The TSLiteralType node to visit. + * @returns {void} + */ + TSLiteralType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSIntersectionType} node The TSIntersectionType node to visit. + * @returns {void} + */ + TSIntersectionType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSConditionalType} node The TSConditionalType node to visit. + * @returns {void} + */ + TSConditionalType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSIndexedAccessType} node The TSIndexedAccessType node to visit. + * @returns {void} + */ + TSIndexedAccessType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSMappedType} node The TSMappedType node to visit. + * @returns {void} + */ + TSMappedType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSOptionalType} node The TSOptionalType node to visit. + * @returns {void} + */ + TSOptionalType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSParenthesizedType} node The TSParenthesizedType node to visit. + * @returns {void} + */ + TSParenthesizedType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSRestType} node The TSRestType node to visit. + * @returns {void} + */ + TSRestType(node) { + this.visitTypeNodes(node); + } + + /** + * @param {TSTupleType} node The TSTupleType node to visit. + * @returns {void} + */ + TSTupleType(node) { + this.visitTypeNodes(node); + } + /** * Create reference objects for the object part. (This is `obj.prop`) - * @param {TSTypeQuery} node The TSTypeQuery node to visit. + * @param {TSQualifiedName} node The TSQualifiedName node to visit. * @returns {void} */ TSQualifiedName(node) { @@ -457,7 +584,7 @@ class Referencer extends OriginalReferencer { */ TSMethodSignature(node) { const upperTypeMode = this.typeMode; - const { computed, key, typeParameters, params, typeAnnotation } = node; + const { computed, key, typeParameters, params, returnType } = node; if (computed) { this.typeMode = false; @@ -469,7 +596,7 @@ class Referencer extends OriginalReferencer { } this.visit(typeParameters); params.forEach(this.visit, this); - this.visit(typeAnnotation); // Maybe returnType? + this.visit(returnType); this.typeMode = upperTypeMode; } @@ -556,6 +683,12 @@ class Referencer extends OriginalReferencer { this.visit(body); } + TSTypeAliasDeclaration(node) { + this.typeMode = true; + this.visitChildren(node); + this.typeMode = false; + } + /** * Process the module block. * @param {TSModuleBlock} node The TSModuleBlock node to visit. @@ -583,11 +716,11 @@ class Referencer extends OriginalReferencer { * @returns {void} */ TSImportEqualsDeclaration(node) { - const { name, moduleReference } = node; - if (name && name.type === "Identifier") { + const { id, moduleReference } = node; + if (id && id.type === "Identifier") { this.currentScope().__define( - name, - new Definition("ImportBinding", name, node, null, null, null) + id, + new Definition("ImportBinding", id, node, null, null, null) ); } this.visit(moduleReference); @@ -628,6 +761,21 @@ class Referencer extends OriginalReferencer { decorators.forEach(this.visit, this); } } + + /** + * Process all child of type nodes + * @param {any} node node to be processed + * @returns {void} + */ + visitTypeNodes(node) { + if (this.typeMode) { + this.visitChildren(node); + } else { + this.typeMode = true; + this.visitChildren(node); + this.typeMode = false; + } + } } module.exports = function(ast, parserOptions, extraOptions) { diff --git a/package.json b/package.json index fc21e87..54316fc 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dependencies": { "eslint-scope": "^4.0.0", "eslint-visitor-keys": "^1.0.0", - "typescript-estree": "5.3.0" + "typescript-estree": "18.0.0" }, "devDependencies": { "eslint": "^4.19.1", @@ -57,7 +57,7 @@ "npm-license": "0.3.3", "shelljs": "0.8.2", "shelljs-nodecli": "0.1.1", - "typescript": "~3.1.1" + "typescript": "~3.2.1" }, "jest": { "testEnvironment": "node", diff --git a/parser.js b/parser.js index 59f5836..9774d4c 100644 --- a/parser.js +++ b/parser.js @@ -41,16 +41,8 @@ exports.parseForESLint = function parseForESLint(code, options) { traverser.traverse(ast, { enter: node => { switch (node.type) { - // Just for backward compatibility. - case "DeclareFunction": - if (!node.body) { - node.type = `TSEmptyBody${node.type}`; - } - break; - // Function#body cannot be null in ESTree spec. case "FunctionExpression": - case "FunctionDeclaration": if (!node.body) { node.type = `TSEmptyBody${node.type}`; } diff --git a/tests/fixtures/ecma-features/bigIntLiterals/binary.src.js b/tests/fixtures/ecma-features/bigIntLiterals/binary.src.js new file mode 100644 index 0000000..2b13801 --- /dev/null +++ b/tests/fixtures/ecma-features/bigIntLiterals/binary.src.js @@ -0,0 +1 @@ +0b1n; diff --git a/tests/fixtures/ecma-features/bigIntLiterals/decimal.src.js b/tests/fixtures/ecma-features/bigIntLiterals/decimal.src.js new file mode 100644 index 0000000..fe03424 --- /dev/null +++ b/tests/fixtures/ecma-features/bigIntLiterals/decimal.src.js @@ -0,0 +1 @@ +1n; diff --git a/tests/fixtures/ecma-features/bigIntLiterals/hex.src.js b/tests/fixtures/ecma-features/bigIntLiterals/hex.src.js new file mode 100644 index 0000000..204f239 --- /dev/null +++ b/tests/fixtures/ecma-features/bigIntLiterals/hex.src.js @@ -0,0 +1 @@ +0x1n; diff --git a/tests/fixtures/ecma-features/bigIntLiterals/octal.src.js b/tests/fixtures/ecma-features/bigIntLiterals/octal.src.js new file mode 100644 index 0000000..f2ce84f --- /dev/null +++ b/tests/fixtures/ecma-features/bigIntLiterals/octal.src.js @@ -0,0 +1 @@ +0o1n; diff --git a/tests/fixtures/scope-analysis/export-as-namespace.ts b/tests/fixtures/scope-analysis/export-as-namespace.ts new file mode 100644 index 0000000..ff8bbad --- /dev/null +++ b/tests/fixtures/scope-analysis/export-as-namespace.ts @@ -0,0 +1 @@ +export as namespace a; diff --git a/tests/fixtures/scope-analysis/expression-as.ts b/tests/fixtures/scope-analysis/expression-as.ts new file mode 100644 index 0000000..952b959 --- /dev/null +++ b/tests/fixtures/scope-analysis/expression-as.ts @@ -0,0 +1 @@ +(a as number as any) = 42; diff --git a/tests/fixtures/scope-analysis/rest-element.ts b/tests/fixtures/scope-analysis/rest-element.ts new file mode 100644 index 0000000..6f14540 --- /dev/null +++ b/tests/fixtures/scope-analysis/rest-element.ts @@ -0,0 +1 @@ +function foo(...args: string[]) {} diff --git a/tests/fixtures/scope-analysis/type-alias.ts b/tests/fixtures/scope-analysis/type-alias.ts new file mode 100644 index 0000000..188a66b --- /dev/null +++ b/tests/fixtures/scope-analysis/type-alias.ts @@ -0,0 +1 @@ +type foo = string diff --git a/tests/fixtures/scope-analysis/type-parameter.ts b/tests/fixtures/scope-analysis/type-parameter.ts new file mode 100644 index 0000000..f5f233e --- /dev/null +++ b/tests/fixtures/scope-analysis/type-parameter.ts @@ -0,0 +1 @@ +function f() {} diff --git a/tests/fixtures/scope-analysis/types-array-type.src.ts b/tests/fixtures/scope-analysis/types-array-type.src.ts new file mode 100644 index 0000000..5d038fc --- /dev/null +++ b/tests/fixtures/scope-analysis/types-array-type.src.ts @@ -0,0 +1 @@ +type Foo = string[] diff --git a/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts b/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts new file mode 100644 index 0000000..c776486 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-conditional-with-null.src.ts @@ -0,0 +1 @@ +let x: number extends string ? boolean : null; diff --git a/tests/fixtures/scope-analysis/types-conditional.src.ts b/tests/fixtures/scope-analysis/types-conditional.src.ts new file mode 100644 index 0000000..da72fcb --- /dev/null +++ b/tests/fixtures/scope-analysis/types-conditional.src.ts @@ -0,0 +1 @@ +let x: number extends string ? boolean : string; diff --git a/tests/fixtures/scope-analysis/types-indexed.src.ts b/tests/fixtures/scope-analysis/types-indexed.src.ts new file mode 100644 index 0000000..4a5809f --- /dev/null +++ b/tests/fixtures/scope-analysis/types-indexed.src.ts @@ -0,0 +1 @@ +let x: T[K]; diff --git a/tests/fixtures/scope-analysis/types-infer.ts b/tests/fixtures/scope-analysis/types-infer.ts new file mode 100644 index 0000000..45ab5c0 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-infer.ts @@ -0,0 +1,5 @@ +type Unpacked = + T extends (infer U)[] ? U : + T extends infer U ? U : + T extends Promise ? U : + T; diff --git a/tests/fixtures/scope-analysis/types-intersection-type.src.ts b/tests/fixtures/scope-analysis/types-intersection-type.src.ts new file mode 100644 index 0000000..93da940 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-intersection-type.src.ts @@ -0,0 +1 @@ +type LinkedList = T & { next: LinkedList }; diff --git a/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts b/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts new file mode 100644 index 0000000..a7a1183 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts @@ -0,0 +1 @@ +let map: { -readonly [P in string]-?: number }; diff --git a/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts b/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts new file mode 100644 index 0000000..854fb5d --- /dev/null +++ b/tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts @@ -0,0 +1 @@ +let map: { +readonly [P in string]+?: number; }; diff --git a/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts b/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts new file mode 100644 index 0000000..ef13a05 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-mapped-readonly.src.ts @@ -0,0 +1 @@ +let map: { readonly [P in string]?: number; }; diff --git a/tests/fixtures/scope-analysis/types-mapped.src.ts b/tests/fixtures/scope-analysis/types-mapped.src.ts new file mode 100644 index 0000000..aca2ba1 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-mapped.src.ts @@ -0,0 +1 @@ +let map: { [P in string]: number; }; diff --git a/tests/fixtures/scope-analysis/types-nested-types.src.ts b/tests/fixtures/scope-analysis/types-nested-types.src.ts new file mode 100644 index 0000000..adaf9a3 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-nested-types.src.ts @@ -0,0 +1 @@ +type Foo = [number, string?, boolean?] | [{}, [number?] | null & boolean[]] & {} diff --git a/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts b/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts new file mode 100644 index 0000000..5a03e27 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-parenthesized-type.src.ts @@ -0,0 +1 @@ +type Foo = (string | number) diff --git a/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts b/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts new file mode 100644 index 0000000..e38dfca --- /dev/null +++ b/tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts @@ -0,0 +1 @@ +let x: Array>; diff --git a/tests/fixtures/scope-analysis/types-reference-generic.src.ts b/tests/fixtures/scope-analysis/types-reference-generic.src.ts new file mode 100644 index 0000000..4925bd4 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-reference-generic.src.ts @@ -0,0 +1 @@ +let x: Array; diff --git a/tests/fixtures/scope-analysis/types-reference.src.ts b/tests/fixtures/scope-analysis/types-reference.src.ts new file mode 100644 index 0000000..330fb1d --- /dev/null +++ b/tests/fixtures/scope-analysis/types-reference.src.ts @@ -0,0 +1 @@ +let x: T; diff --git a/tests/fixtures/scope-analysis/types-tuple-empty.src.ts b/tests/fixtures/scope-analysis/types-tuple-empty.src.ts new file mode 100644 index 0000000..f7cd7b5 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-tuple-empty.src.ts @@ -0,0 +1 @@ +let x: []; diff --git a/tests/fixtures/scope-analysis/types-tuple-optional.src.ts b/tests/fixtures/scope-analysis/types-tuple-optional.src.ts new file mode 100644 index 0000000..3b8d21b --- /dev/null +++ b/tests/fixtures/scope-analysis/types-tuple-optional.src.ts @@ -0,0 +1 @@ +let x: [string, number?, (string | number)?] diff --git a/tests/fixtures/scope-analysis/types-tuple-rest.src.ts b/tests/fixtures/scope-analysis/types-tuple-rest.src.ts new file mode 100644 index 0000000..d7719b2 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-tuple-rest.src.ts @@ -0,0 +1 @@ +let x: [string, ...number[]] diff --git a/tests/fixtures/scope-analysis/types-tuple-type.src.ts b/tests/fixtures/scope-analysis/types-tuple-type.src.ts new file mode 100644 index 0000000..75a6d8e --- /dev/null +++ b/tests/fixtures/scope-analysis/types-tuple-type.src.ts @@ -0,0 +1 @@ +type Foo = [string, string?] diff --git a/tests/fixtures/scope-analysis/types-tuple.src.ts b/tests/fixtures/scope-analysis/types-tuple.src.ts new file mode 100644 index 0000000..53c8e72 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-tuple.src.ts @@ -0,0 +1 @@ +let x: [number, number, number]; diff --git a/tests/fixtures/scope-analysis/types-type-literal.src.ts b/tests/fixtures/scope-analysis/types-type-literal.src.ts new file mode 100644 index 0000000..4193f36 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-type-literal.src.ts @@ -0,0 +1 @@ +let obj: { x: number }; diff --git a/tests/fixtures/scope-analysis/types-type-operator.src.ts b/tests/fixtures/scope-analysis/types-type-operator.src.ts new file mode 100644 index 0000000..1d23f96 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-type-operator.src.ts @@ -0,0 +1,2 @@ +let x: keyof T; +let y: unique symbol; diff --git a/tests/fixtures/scope-analysis/types-typeof.src.ts b/tests/fixtures/scope-analysis/types-typeof.src.ts new file mode 100644 index 0000000..eebcd19 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-typeof.src.ts @@ -0,0 +1 @@ +let x: typeof y.z; diff --git a/tests/fixtures/scope-analysis/types-union-intersection.src.ts b/tests/fixtures/scope-analysis/types-union-intersection.src.ts new file mode 100644 index 0000000..93f391f --- /dev/null +++ b/tests/fixtures/scope-analysis/types-union-intersection.src.ts @@ -0,0 +1,4 @@ +let union: number | null | undefined; +let intersection: number & string; +let precedence1: number | string & boolean; +let precedence2: number & string | boolean; diff --git a/tests/fixtures/scope-analysis/types-union-type.src.ts b/tests/fixtures/scope-analysis/types-union-type.src.ts new file mode 100644 index 0000000..a2cfaf9 --- /dev/null +++ b/tests/fixtures/scope-analysis/types-union-type.src.ts @@ -0,0 +1 @@ +type Foo = string & number diff --git a/tests/fixtures/typescript/basics/export-default-anonymous-function.src.ts b/tests/fixtures/typescript/basics/export-default-anonymous-function.src.ts new file mode 100644 index 0000000..70b8a55 --- /dev/null +++ b/tests/fixtures/typescript/basics/export-default-anonymous-function.src.ts @@ -0,0 +1,3 @@ +declare module "foo" { + export default function (): string; +} diff --git a/tests/integration/declared-empty-body-functions-issue-162/package.json b/tests/integration/declared-empty-body-functions-issue-162/package.json index 9029571..4944126 100644 --- a/tests/integration/declared-empty-body-functions-issue-162/package.json +++ b/tests/integration/declared-empty-body-functions-issue-162/package.json @@ -8,6 +8,6 @@ "devDependencies": { "eslint": "4.19.1", "jest": "23.1.0", - "typescript": "~3.1.1" + "typescript": "~3.2.1" } -} \ No newline at end of file +} diff --git a/tests/integration/jsdoc-indent-issues-344-422/package.json b/tests/integration/jsdoc-indent-issues-344-422/package.json index 9029571..4944126 100644 --- a/tests/integration/jsdoc-indent-issues-344-422/package.json +++ b/tests/integration/jsdoc-indent-issues-344-422/package.json @@ -8,6 +8,6 @@ "devDependencies": { "eslint": "4.19.1", "jest": "23.1.0", - "typescript": "~3.1.1" + "typescript": "~3.2.1" } -} \ No newline at end of file +} diff --git a/tests/integration/method-overloads-issue-389/package.json b/tests/integration/method-overloads-issue-389/package.json index 9029571..4944126 100644 --- a/tests/integration/method-overloads-issue-389/package.json +++ b/tests/integration/method-overloads-issue-389/package.json @@ -8,6 +8,6 @@ "devDependencies": { "eslint": "4.19.1", "jest": "23.1.0", - "typescript": "~3.1.1" + "typescript": "~3.2.1" } -} \ No newline at end of file +} diff --git a/tests/integration/no-redeclare-overloaded-functions-issue-402/package.json b/tests/integration/no-redeclare-overloaded-functions-issue-402/package.json index 9029571..4944126 100644 --- a/tests/integration/no-redeclare-overloaded-functions-issue-402/package.json +++ b/tests/integration/no-redeclare-overloaded-functions-issue-402/package.json @@ -8,6 +8,6 @@ "devDependencies": { "eslint": "4.19.1", "jest": "23.1.0", - "typescript": "~3.1.1" + "typescript": "~3.2.1" } -} \ No newline at end of file +} diff --git a/tests/integration/range-error-indent-issue-333/package.json b/tests/integration/range-error-indent-issue-333/package.json index 9029571..4944126 100644 --- a/tests/integration/range-error-indent-issue-333/package.json +++ b/tests/integration/range-error-indent-issue-333/package.json @@ -8,6 +8,6 @@ "devDependencies": { "eslint": "4.19.1", "jest": "23.1.0", - "typescript": "~3.1.1" + "typescript": "~3.2.1" } -} \ No newline at end of file +} diff --git a/tests/lib/__snapshots__/ecma-features.js.snap b/tests/lib/__snapshots__/ecma-features.js.snap index 00a985d..591436e 100644 --- a/tests/lib/__snapshots__/ecma-features.js.snap +++ b/tests/lib/__snapshots__/ecma-features.js.snap @@ -2375,6 +2375,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-default-param-eval.sr Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -2730,6 +2731,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-dup-params.src 1`] = Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3072,6 +3074,7 @@ Object { "body": Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3404,6 +3407,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-eval-return.src 1`] = Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3669,6 +3673,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-octal.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3952,6 +3957,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-arguments.src 1 Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4289,6 +4295,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-eval.src 1`] = Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4626,6 +4633,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-names.src 1`] = Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4963,6 +4971,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-no-paren-argume Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -5210,6 +5219,7 @@ exports[`ecmaFeatures fixtures/arrowFunctions/error-strict-param-no-paren-eval.s Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -9142,6 +9152,398 @@ Object { } `; +exports[`ecmaFeatures fixtures/bigIntLiterals/binary.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "raw": "0b1n", + "type": "BigIntLiteral", + "value": "0b1", + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "0b1n", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`ecmaFeatures fixtures/bigIntLiterals/decimal.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 2, + ], + "raw": "1n", + "type": "BigIntLiteral", + "value": "1", + }, + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 2, + ], + "type": "Identifier", + "value": "1n", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 2, + "line": 1, + }, + }, + "range": Array [ + 2, + 3, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`ecmaFeatures fixtures/bigIntLiterals/hex.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "raw": "0x1n", + "type": "BigIntLiteral", + "value": "0x1", + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "0x1n", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`ecmaFeatures fixtures/bigIntLiterals/octal.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "raw": "0o1n", + "type": "BigIntLiteral", + "value": "0o1", + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "ExpressionStatement", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "0o1n", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`ecmaFeatures fixtures/binaryLiterals/invalid.src 1`] = `"';' expected."`; exports[`ecmaFeatures fixtures/binaryLiterals/lowercase.src 1`] = ` @@ -41186,7 +41588,7 @@ Object { 1, 23, ], - "type": "ObjectPattern", + "type": "ObjectExpression", }, "loc": Object { "end": Object { @@ -93032,6 +93434,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/error-proto-prop Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -93733,6 +94136,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/error-proto-stri Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -94436,6 +94840,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/strict-duplicate Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -94958,6 +95363,7 @@ exports[`ecmaFeatures fixtures/objectLiteralDuplicateProperties/strict-duplicate Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -99240,6 +99646,7 @@ exports[`ecmaFeatures fixtures/octalLiterals/strict-uppercase.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -101637,7 +102044,6 @@ Object { "body": Array [ Object { "async": false, - "body": null, "expression": false, "generator": false, "id": Object { @@ -101727,7 +102133,7 @@ Object { 0, 24, ], - "type": "TSEmptyBodyFunctionDeclaration", + "type": "TSDeclareFunction", }, ], "comments": Array [], @@ -101955,7 +102361,6 @@ Object { "body": Array [ Object { "async": false, - "body": null, "expression": false, "generator": false, "id": Object { @@ -102063,7 +102468,7 @@ Object { 0, 23, ], - "type": "TSEmptyBodyFunctionDeclaration", + "type": "TSDeclareFunction", }, ], "comments": Array [], @@ -107373,6 +107778,7 @@ exports[`ecmaFeatures fixtures/unicodeCodePointEscapes/basic-string-literal.src Object { "body": Array [ Object { + "directive": "\\\\u{714E}\\\\u{8336}", "expression": Object { "loc": Object { "end": Object { @@ -107471,6 +107877,7 @@ exports[`ecmaFeatures fixtures/unicodeCodePointEscapes/complex-string-literal.sr Object { "body": Array [ Object { + "directive": "\\\\u{20BB7}\\\\u{10FFFF}\\\\u{1}", "expression": Object { "loc": Object { "end": Object { diff --git a/tests/lib/__snapshots__/scope-analysis.js.snap b/tests/lib/__snapshots__/scope-analysis.js.snap index 6316b14..561adcd 100644 --- a/tests/lib/__snapshots__/scope-analysis.js.snap +++ b/tests/lib/__snapshots__/scope-analysis.js.snap @@ -1689,7 +1689,7 @@ Object { 0, 37, ], - "type": "TSEmptyBodyDeclareFunction", + "type": "TSDeclareFunction", }, "parent": null, "type": "FunctionName", @@ -3396,6 +3396,100 @@ Object { } `; +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/export-as-namespace.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 23, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 0, + "from": Object { + "$ref": 1, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/expression-as.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 27, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 0, + "from": Object { + "$ref": 1, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 1, + 2, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis tests/fixtures/scope-analysis/expression-type-parameters.ts 1`] = ` Object { "$id": 14, @@ -4094,7 +4188,7 @@ Object { 0, 18, ], - "type": "TSEmptyBodyFunctionDeclaration", + "type": "TSDeclareFunction", }, "parent": null, "type": "FunctionName", @@ -5298,166 +5392,96 @@ Object { } `; -exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-annotations.ts 1`] = ` +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/rest-element.ts 1`] = ` Object { - "$id": 7, + "$id": 4, "block": Object { "range": Array [ 0, - 103, + 35, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 6, + "$id": 3, "block": Object { "range": Array [ - 32, - 102, + 0, + 34, ], - "type": "ClassDeclaration", + "type": "FunctionDeclaration", }, - "childScopes": Array [ - Object { - "$id": 5, - "block": Object { - "range": Array [ - 47, - 100, - ], - "type": "FunctionExpression", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "function", - "upperScope": Object { - "$ref": 6, - }, - "variableMap": Object { - "a": Object { - "$ref": 4, - }, - "arguments": Object { - "$ref": 3, - }, - }, - "variableScope": Object { - "$ref": 5, - }, - "variables": Array [ - Object { - "$id": 3, - "defs": Array [], - "eslintUsed": undefined, - "identifiers": Array [], - "name": "arguments", - "references": Array [], - "scope": Object { - "$ref": 5, - }, - }, - Object { - "$id": 4, - "defs": Array [ - Object { - "name": Object { - "name": "a", - "range": Array [ - 48, - 59, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 47, - 100, - ], - "type": "FunctionExpression", - }, - "parent": null, - "type": "Parameter", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "a", - "range": Array [ - 48, - 59, - ], - "type": "Identifier", - }, - ], - "name": "a", - "references": Array [], - "scope": Object { - "$ref": 5, - }, - }, - ], - }, - ], + "childScopes": Array [], "functionExpressionScope": false, - "isStrict": true, + "isStrict": false, "references": Array [], "throughReferences": Array [], - "type": "class", + "type": "function", "upperScope": Object { - "$ref": 7, + "$ref": 4, }, "variableMap": Object { - "C": Object { + "args": Object { "$ref": 2, }, + "arguments": Object { + "$ref": 1, + }, }, "variableScope": Object { - "$ref": 7, + "$ref": 3, }, "variables": Array [ + Object { + "$id": 1, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 3, + }, + }, Object { "$id": 2, "defs": Array [ Object { "name": Object { - "name": "C", + "name": "args", "range": Array [ - 38, - 39, + 16, + 20, ], "type": "Identifier", }, "node": Object { "range": Array [ - 32, - 102, + 0, + 34, ], - "type": "ClassDeclaration", + "type": "FunctionDeclaration", }, - "parent": undefined, - "type": "ClassName", + "parent": null, + "type": "Parameter", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "C", + "name": "args", "range": Array [ - 38, - 39, + 16, + 20, ], "type": "Identifier", }, ], - "name": "C", + "name": "args", "references": Array [], "scope": Object { - "$ref": 6, + "$ref": 3, }, }, ], @@ -5470,15 +5494,12 @@ Object { "type": "global", "upperScope": null, "variableMap": Object { - "C": Object { - "$ref": 1, - }, - "a": Object { + "foo": Object { "$ref": 0, }, }, "variableScope": Object { - "$ref": 7, + "$ref": 4, }, "variables": Array [ Object { @@ -5486,25 +5507,277 @@ Object { "defs": Array [ Object { "name": Object { - "name": "a", + "name": "foo", "range": Array [ - 20, - 31, + 9, + 12, ], "type": "Identifier", }, "node": Object { "range": Array [ - 20, - 31, + 0, + 34, ], - "type": "VariableDeclarator", + "type": "FunctionDeclaration", }, - "parent": Object { - "range": Array [ - 16, - 31, - ], + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-alias.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 18, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-annotations.ts 1`] = ` +Object { + "$id": 7, + "block": Object { + "range": Array [ + 0, + 103, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 6, + "block": Object { + "range": Array [ + 32, + 102, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [ + Object { + "$id": 5, + "block": Object { + "range": Array [ + 47, + 100, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "a": Object { + "$ref": 4, + }, + "arguments": Object { + "$ref": 3, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 3, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 4, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 47, + 100, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "class", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "C": Object { + "$ref": 2, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [ + Object { + "name": Object { + "name": "C", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 32, + 102, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "C", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + ], + "name": "C", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "C": Object { + "$ref": 1, + }, + "a": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 20, + 31, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 16, + 31, + ], "type": "VariableDeclaration", }, "type": "Variable", @@ -5605,7 +5878,7 @@ Object { 21, 26, ], - "type": "TSTypeAssertionExpression", + "type": "TSTypeAssertion", }, }, Object { @@ -5690,7 +5963,118 @@ Object { } `; -exports[`TypeScript scope analysis tests/fixtures/scope-analysis/typeof.ts 1`] = ` +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-parameter.ts 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 19, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "f": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "f", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 18, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "f", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + ], + "name": "f", + "references": Array [], + "scope": Object { + "$ref": 3, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/typeof.ts 1`] = ` Object { "$id": 3, "block": Object { @@ -5877,7 +6261,7 @@ Object { 27, 40, ], - "type": "TSTypeAssertionExpression", + "type": "TSTypeAssertion", }, }, Object { @@ -7060,3 +7444,1764 @@ Object { ], } `; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-array-type.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 20, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-conditional.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 49, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 48, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-conditional-with-null.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 47, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-indexed.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 13, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 11, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 11, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 12, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 11, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-infer.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 147, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-intersection-type.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 50, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-mapped.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 37, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "map": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "map", + "range": Array [ + 4, + 35, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 35, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 36, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "map", + "range": Array [ + 4, + 35, + ], + "type": "Identifier", + }, + ], + "name": "map", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-mapped-readonly.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 47, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "map": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "map", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "map", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + }, + ], + "name": "map", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-mapped-readonly-minus.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 48, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "map": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "map", + "range": Array [ + 4, + 46, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 46, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 47, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "map", + "range": Array [ + 4, + 46, + ], + "type": "Identifier", + }, + ], + "name": "map", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-mapped-readonly-plus.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 49, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "map": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "map", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 48, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "map", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + }, + ], + "name": "map", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-nested-types.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 81, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-parenthesized-type.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-reference.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 10, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 8, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 8, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 9, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 8, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-reference-generic.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 22, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 20, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 20, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 21, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 20, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 27, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 27, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 28, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 27, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-tuple.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 33, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 31, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 31, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 32, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 31, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-tuple-empty.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 11, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 9, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 9, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 10, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 9, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-tuple-optional.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 45, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 44, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 44, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 44, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 44, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-tuple-rest.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 28, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 28, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 28, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 28, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-tuple-type.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-type-literal.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 24, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "obj": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "obj", + "range": Array [ + 4, + 22, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 22, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 23, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "obj", + "range": Array [ + 4, + 22, + ], + "type": "Identifier", + }, + ], + "name": "obj", + "references": Array [], + "scope": Object { + "$ref": 1, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-type-operator.src.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 38, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + "y": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 14, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 14, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 15, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 14, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "y", + "range": Array [ + 20, + 36, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 20, + 36, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 16, + 37, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "y", + "range": Array [ + 20, + 36, + ], + "type": "Identifier", + }, + ], + "name": "y", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-typeof.src.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 19, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 2, + }, + "identifier": Object { + "name": "y", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 1, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "x", + "range": Array [ + 4, + 17, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 17, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 18, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "x", + "range": Array [ + 4, + 17, + ], + "type": "Identifier", + }, + ], + "name": "x", + "references": Array [], + "scope": Object { + "$ref": 2, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-union-intersection.src.ts 1`] = ` +Object { + "$id": 4, + "block": Object { + "range": Array [ + 0, + 161, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "intersection": Object { + "$ref": 1, + }, + "precedence1": Object { + "$ref": 2, + }, + "precedence2": Object { + "$ref": 3, + }, + "union": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "union", + "range": Array [ + 4, + 36, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 4, + 36, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 37, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "union", + "range": Array [ + 4, + 36, + ], + "type": "Identifier", + }, + ], + "name": "union", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "intersection", + "range": Array [ + 42, + 71, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 42, + 71, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 38, + 72, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "intersection", + "range": Array [ + 42, + 71, + ], + "type": "Identifier", + }, + ], + "name": "intersection", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + Object { + "$id": 2, + "defs": Array [ + Object { + "name": Object { + "name": "precedence1", + "range": Array [ + 77, + 115, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 77, + 115, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 73, + 116, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "precedence1", + "range": Array [ + 77, + 115, + ], + "type": "Identifier", + }, + ], + "name": "precedence1", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "precedence2", + "range": Array [ + 121, + 159, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 121, + 159, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 117, + 160, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "precedence2", + "range": Array [ + 121, + 159, + ], + "type": "Identifier", + }, + ], + "name": "precedence2", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/types-union-type.src.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 27, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; diff --git a/tests/lib/__snapshots__/tsx.js.snap b/tests/lib/__snapshots__/tsx.js.snap index 4025e7b..2c696e0 100644 --- a/tests/lib/__snapshots__/tsx.js.snap +++ b/tests/lib/__snapshots__/tsx.js.snap @@ -500,148 +500,128 @@ Object { "type": "ImportDeclaration", }, Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 5, - "line": 2, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "name": "Props", + "range": Array [ + 36, + 41, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 31, + 63, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 13, + "line": 2, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, }, + "name": "title", + "range": Array [ + 48, + 53, + ], + "type": "Identifier", }, - "name": "Props", - "range": Array [ - 36, - 41, - ], - "type": "Identifier", - }, - "init": Object { "loc": Object { "end": Object { - "column": 1, - "line": 4, + "column": 15, + "line": 3, }, "start": Object { - "column": 13, - "line": 2, + "column": 2, + "line": 3, }, }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 7, - "line": 3, - }, - "start": Object { - "column": 2, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 48, - 53, - ], - "type": "Identifier", + "range": Array [ + 48, + 61, + ], + "type": "TSPropertySignature", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, }, + "start": Object { + "column": 7, + "line": 3, + }, + }, + "range": Array [ + 53, + 61, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { "loc": Object { "end": Object { "column": 15, "line": 3, }, "start": Object { - "column": 2, + "column": 9, "line": 3, }, }, "range": Array [ - 48, + 55, 61, ], - "type": "TSPropertySignature", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 3, - }, - "start": Object { - "column": 7, - "line": 3, - }, - }, - "range": Array [ - 53, - 61, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 3, - }, - "start": Object { - "column": 9, - "line": 3, - }, - }, - "range": Array [ - 55, - 61, - ], - "type": "TSStringKeyword", - }, - }, + "type": "TSStringKeyword", }, - ], - "range": Array [ - 44, - 63, - ], - "type": "TSTypeLiteral", - }, - "loc": Object { - "end": Object { - "column": 1, - "line": 4, - }, - "start": Object { - "column": 5, - "line": 2, }, }, - "range": Array [ - 36, - 63, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 1, - "line": 4, - }, - "start": Object { - "column": 0, - "line": 2, - }, + ], + "range": Array [ + 44, + 63, + ], + "type": "TSTypeLiteral", }, - "range": Array [ - 31, - 63, - ], - "type": "VariableDeclaration", }, Object { "declaration": Object { diff --git a/tests/lib/__snapshots__/typescript.js.snap b/tests/lib/__snapshots__/typescript.js.snap index dc29543..dcb703d 100644 --- a/tests/lib/__snapshots__/typescript.js.snap +++ b/tests/lib/__snapshots__/typescript.js.snap @@ -82,7 +82,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, "range": Array [ 13, 14, @@ -398,7 +415,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + }, "range": Array [ 11, 36, @@ -2892,7 +2926,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -3301,7 +3334,24 @@ Object { "line": 1, }, }, - "name": "X", + "name": Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "name": "X", + "range": Array [ + 1, + 2, + ], + "type": "Identifier", + }, "range": Array [ 1, 2, @@ -6855,7 +6905,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 77, @@ -6887,7 +6937,7 @@ Object { 66, 77, ], - "type": "ClassImplements", + "type": "TSClassImplements", }, ], "loc": Object { @@ -7241,7 +7291,24 @@ Object { "line": 1, }, }, - "name": "A", + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 10, + 11, + ], + "type": "Identifier", + }, "range": Array [ 10, 11, @@ -7715,7 +7782,24 @@ Object { "line": 1, }, }, - "name": "A", + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 10, + 11, + ], + "type": "Identifier", + }, "range": Array [ 10, 21, @@ -8146,7 +8230,24 @@ Object { "line": 2, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + }, "range": Array [ 21, 22, @@ -8593,7 +8694,24 @@ Object { "line": 2, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + }, "range": Array [ 21, 28, @@ -8978,7 +9096,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 24, @@ -9010,7 +9128,7 @@ Object { 21, 24, ], - "type": "ClassImplements", + "type": "TSClassImplements", }, ], "loc": Object { @@ -9203,7 +9321,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 56, @@ -9235,7 +9353,7 @@ Object { 45, 56, ], - "type": "ClassImplements", + "type": "TSClassImplements", }, ], "loc": Object { @@ -9481,7 +9599,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 24, @@ -9513,7 +9631,7 @@ Object { 21, 24, ], - "type": "ClassImplements", + "type": "TSClassImplements", "typeParameters": Object { "loc": Object { "end": Object { @@ -9814,7 +9932,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 24, @@ -9846,7 +9964,7 @@ Object { 21, 24, ], - "type": "ClassImplements", + "type": "TSClassImplements", "typeParameters": Object { "loc": Object { "end": Object { @@ -10448,29 +10566,12 @@ Object { "line": 1, }, }, + "members": Array [], "range": Array [ 33, 35, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 35, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, - }, - "members": Array [], - "range": Array [ - 33, - 35, - ], - "type": "TSTypeLiteral", - }, + "type": "TSTypeLiteral", }, ], "range": Array [ @@ -10490,7 +10591,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + }, "range": Array [ 11, 36, @@ -10544,7 +10662,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 38, @@ -10576,7 +10694,7 @@ Object { 123, 124, ], - "type": "ClassImplements", + "type": "TSClassImplements", }, ], "loc": Object { @@ -10741,7 +10859,6 @@ Object { "type": "ClassDeclaration", }, Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -10760,7 +10877,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -10796,107 +10912,118 @@ Object { "type": "TSInterfaceDeclaration", }, Object { - "declarations": Array [ - Object { - "id": Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 9, + }, + "start": Object { + "column": 5, + "line": 9, + }, + }, + "name": "Constructor", + "range": Array [ + 163, + 174, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 48, + "line": 9, + }, + "start": Object { + "column": 0, + "line": 9, + }, + }, + "range": Array [ + 158, + 206, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 9, + }, + "start": Object { + "column": 22, + "line": 9, + }, + }, + "params": Array [ + Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 9, + }, + "start": Object { + "column": 30, + "line": 9, + }, + }, + "name": "args", + "range": Array [ + 188, + 192, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 16, + "column": 41, "line": 9, }, "start": Object { - "column": 5, + "column": 27, "line": 9, }, }, - "name": "Constructor", "range": Array [ - 163, - 174, + 185, + 199, ], - "type": "Identifier", - }, - "init": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 9, - }, - "start": Object { - "column": 22, - "line": 9, + "type": "RestElement", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 9, + }, + "start": Object { + "column": 34, + "line": 9, + }, }, - }, - "parameters": Array [ - Object { - "argument": Object { + "range": Array [ + 192, + 199, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementType": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 9, }, "start": Object { - "column": 30, + "column": 36, "line": 9, }, }, - "name": "args", "range": Array [ - 188, - 199, + 194, + 197, ], - "type": "Identifier", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 41, - "line": 9, - }, - "start": Object { - "column": 34, - "line": 9, - }, - }, - "range": Array [ - 192, - 199, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "elementType": Object { - "loc": Object { - "end": Object { - "column": 39, - "line": 9, - }, - "start": Object { - "column": 36, - "line": 9, - }, - }, - "range": Array [ - 194, - 197, - ], - "type": "TSAnyKeyword", - }, - "loc": Object { - "end": Object { - "column": 41, - "line": 9, - }, - "start": Object { - "column": 36, - "line": 9, - }, - }, - "range": Array [ - 194, - 199, - ], - "type": "TSArrayType", - }, - }, + "type": "TSAnyKeyword", }, "loc": Object { "end": Object { @@ -10904,146 +11031,131 @@ Object { "line": 9, }, "start": Object { - "column": 27, + "column": 36, "line": 9, }, }, "range": Array [ - 185, + 194, 199, ], - "type": "RestElement", + "type": "TSArrayType", }, - ], + }, + }, + ], + "range": Array [ + 180, + 205, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 9, + }, + "start": Object { + "column": 43, + "line": 9, + }, + }, + "range": Array [ + 201, + 205, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 9, + }, + "start": Object { + "column": 46, + "line": 9, + }, + }, "range": Array [ - 180, + 204, 205, ], - "type": "TSConstructorType", - "typeAnnotation": Object { + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { "column": 47, "line": 9, }, "start": Object { - "column": 44, + "column": 46, "line": 9, }, }, + "name": "T", "range": Array [ - 202, + 204, 205, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 9, - }, - "start": Object { - "column": 46, - "line": 9, - }, - }, - "range": Array [ - 204, - 205, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 47, - "line": 9, - }, - "start": Object { - "column": 46, - "line": 9, - }, - }, - "name": "T", - "range": Array [ - 204, - 205, - ], - "type": "Identifier", - }, - }, + "type": "Identifier", }, - "typeParameters": null, }, - "loc": Object { - "end": Object { - "column": 48, - "line": 9, - }, - "start": Object { - "column": 5, - "line": 9, - }, + }, + "type": "TSConstructorType", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 9, }, - "range": Array [ - 163, - 206, - ], - "type": "VariableDeclarator", - "typeParameters": Object { + "start": Object { + "column": 16, + "line": 9, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 19, + "column": 18, "line": 9, }, "start": Object { - "column": 16, + "column": 17, "line": 9, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 9, - }, - "start": Object { - "column": 17, - "line": 9, - }, + "name": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 9, + }, + "start": Object { + "column": 17, + "line": 9, }, - "name": "T", - "range": Array [ - 175, - 176, - ], - "type": "TSTypeParameter", }, - ], + "name": "T", + "range": Array [ + 175, + 176, + ], + "type": "Identifier", + }, "range": Array [ - 174, - 177, + 175, + 176, ], - "type": "TSTypeParameterDeclaration", + "type": "TSTypeParameter", }, - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 48, - "line": 9, - }, - "start": Object { - "column": 0, - "line": 9, - }, + ], + "range": Array [ + 174, + 177, + ], + "type": "TSTypeParameterDeclaration", }, - "range": Array [ - 158, - 206, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -19188,7 +19300,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 10, + 11, + ], + "type": "Identifier", + }, "range": Array [ 10, 11, @@ -19466,7 +19595,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 10, + 11, + ], + "type": "Identifier", + }, "range": Array [ 10, 17, @@ -19745,7 +19891,24 @@ Object { "line": 1, }, }, - "name": "__P", + "name": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "name": "__P", + "range": Array [ + 8, + 11, + ], + "type": "Identifier", + }, "range": Array [ 8, 11, @@ -20361,6 +20524,7 @@ Object { ], "type": "ClassBody", }, + "declare": true, "id": Object { "loc": Object { "end": Object { @@ -20640,7 +20804,7 @@ Object { "body": Array [ Object { "async": false, - "body": null, + "declare": true, "expression": false, "generator": false, "id": Object { @@ -20763,7 +20927,7 @@ Object { "type": "TSStringKeyword", }, }, - "type": "TSEmptyBodyDeclareFunction", + "type": "TSDeclareFunction", }, ], "comments": Array [], @@ -21090,7 +21254,7 @@ Object { 9, 11, ], - "type": "ArrayPattern", + "type": "ArrayExpression", }, "type": "AssignmentPattern", }, @@ -21507,83 +21671,121 @@ Object { } `; -exports[`typescript fixtures/basics/export-default-class-with-generic.src 1`] = ` +exports[`typescript fixtures/basics/export-default-anonymous-function.src 1`] = ` Object { "body": Array [ Object { - "declaration": Object { - "body": Object { - "body": Array [], - "loc": Object { - "end": Object { - "column": 1, - "line": 3, + "body": Object { + "body": Array [ + Object { + "declaration": Object { + "async": false, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 39, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "params": Array [], + "range": Array [ + 42, + 62, + ], + "returnType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 53, + 61, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 32, + "line": 2, + }, + }, + "range": Array [ + 55, + 61, + ], + "type": "TSStringKeyword", + }, + }, + "type": "TSDeclareFunction", }, - "start": Object { - "column": 24, - "line": 1, + "loc": Object { + "end": Object { + "column": 39, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, }, + "range": Array [ + 27, + 62, + ], + "type": "ExportDefaultDeclaration", }, - "range": Array [ - 24, - 28, - ], - "type": "ClassBody", - }, - "id": null, + ], "loc": Object { "end": Object { "column": 1, "line": 3, }, "start": Object { - "column": 15, + "column": 21, "line": 1, }, }, "range": Array [ - 15, - 28, + 21, + 64, ], - "superClass": null, - "type": "ClassDeclaration", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, + "type": "TSModuleBlock", + }, + "declare": true, + "id": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 21, - 22, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 20, - 23, - ], - "type": "TSTypeParameterDeclaration", }, + "range": Array [ + 15, + 20, + ], + "raw": "\\"foo\\"", + "type": "Literal", + "value": "foo", }, "loc": Object { "end": Object { @@ -21597,9 +21799,9 @@ Object { }, "range": Array [ 0, - 28, + 64, ], - "type": "ExportDefaultDeclaration", + "type": "TSModuleDeclaration", }, ], "comments": Array [], @@ -21615,14 +21817,14 @@ Object { }, "range": Array [ 0, - 29, + 65, ], - "sourceType": "module", + "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 6, + "column": 7, "line": 1, }, "start": Object { @@ -21632,10 +21834,10 @@ Object { }, "range": Array [ 0, - 6, + 7, ], - "type": "Keyword", - "value": "export", + "type": "Identifier", + "value": "declare", }, Object { "loc": Object { @@ -21644,16 +21846,16 @@ Object { "line": 1, }, "start": Object { - "column": 7, + "column": 8, "line": 1, }, }, "range": Array [ - 7, + 8, 14, ], - "type": "Keyword", - "value": "default", + "type": "Identifier", + "value": "module", }, Object { "loc": Object { @@ -21670,80 +21872,170 @@ Object { 15, 20, ], - "type": "Keyword", - "value": "class", + "type": "String", + "value": "\\"foo\\"", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 22, "line": 1, }, "start": Object { - "column": 20, + "column": 21, "line": 1, }, }, "range": Array [ - 20, 21, + 22, ], "type": "Punctuator", - "value": "<", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 22, - "line": 1, + "column": 10, + "line": 2, }, "start": Object { - "column": 21, - "line": 1, + "column": 4, + "line": 2, }, }, "range": Array [ - 21, - 22, + 27, + 33, ], - "type": "Identifier", - "value": "T", + "type": "Keyword", + "value": "export", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 1, + "column": 18, + "line": 2, }, "start": Object { - "column": 22, - "line": 1, + "column": 11, + "line": 2, }, }, "range": Array [ - 22, - 23, + 34, + 41, + ], + "type": "Keyword", + "value": "default", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 19, + "line": 2, + }, + }, + "range": Array [ + 42, + 50, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 51, + 52, ], "type": "Punctuator", - "value": ">", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 1, + "column": 30, + "line": 2, }, "start": Object { - "column": 24, - "line": 1, + "column": 29, + "line": 2, }, }, "range": Array [ - 24, - 25, + 52, + 53, ], "type": "Punctuator", - "value": "{", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 32, + "line": 2, + }, + }, + "range": Array [ + 55, + 61, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 39, + "line": 2, + }, + "start": Object { + "column": 38, + "line": 2, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": ";", }, Object { "loc": Object { @@ -21757,8 +22049,8 @@ Object { }, }, "range": Array [ - 27, - 28, + 63, + 64, ], "type": "Punctuator", "value": "}", @@ -21768,7 +22060,7 @@ Object { } `; -exports[`typescript fixtures/basics/export-default-class-with-multiple-generics.src 1`] = ` +exports[`typescript fixtures/basics/export-default-class-with-generic.src 1`] = ` Object { "body": Array [ Object { @@ -21781,13 +22073,13 @@ Object { "line": 3, }, "start": Object { - "column": 27, + "column": 24, "line": 1, }, }, "range": Array [ - 27, - 31, + 24, + 28, ], "type": "ClassBody", }, @@ -21804,14 +22096,14 @@ Object { }, "range": Array [ 15, - 31, + 28, ], "superClass": null, "type": "ClassDeclaration", "typeParameters": Object { "loc": Object { "end": Object { - "column": 26, + "column": 23, "line": 1, }, "start": Object { @@ -21831,35 +22123,34 @@ Object { "line": 1, }, }, - "name": "T", - "range": Array [ - 21, - 22, - ], - "type": "TSTypeParameter", - }, - Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, + "name": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", }, - "name": "U", "range": Array [ - 24, - 25, + 21, + 22, ], "type": "TSTypeParameter", }, ], "range": Array [ 20, - 26, + 23, ], "type": "TSTypeParameterDeclaration", }, @@ -21876,7 +22167,7 @@ Object { }, "range": Array [ 0, - 31, + 28, ], "type": "ExportDefaultDeclaration", }, @@ -21894,7 +22185,7 @@ Object { }, "range": Array [ 0, - 32, + 29, ], "sourceType": "module", "tokens": Array [ @@ -22004,7 +22295,7 @@ Object { 23, ], "type": "Punctuator", - "value": ",", + "value": ">", }, Object { "loc": Object { @@ -22021,42 +22312,6 @@ Object { 24, 25, ], - "type": "Identifier", - "value": "U", - }, - Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "range": Array [ - 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": "{", }, @@ -22072,8 +22327,8 @@ Object { }, }, "range": Array [ - 30, - 31, + 27, + 28, ], "type": "Punctuator", "value": "}", @@ -22083,7 +22338,7 @@ Object { } `; -exports[`typescript fixtures/basics/export-named-class-with-generic.src 1`] = ` +exports[`typescript fixtures/basics/export-default-class-with-multiple-generics.src 1`] = ` Object { "body": Array [ Object { @@ -22096,58 +22351,41 @@ Object { "line": 3, }, "start": Object { - "column": 20, + "column": 27, "line": 1, }, }, "range": Array [ - 20, - 24, + 27, + 31, ], "type": "ClassBody", }, - "id": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 1, - }, - "start": Object { - "column": 13, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 13, - 16, - ], - "type": "Identifier", - }, + "id": null, "loc": Object { "end": Object { "column": 1, "line": 3, }, "start": Object { - "column": 7, + "column": 15, "line": 1, }, }, "range": Array [ - 7, - 24, + 15, + 31, ], "superClass": null, "type": "ClassDeclaration", "typeParameters": Object { "loc": Object { "end": Object { - "column": 19, + "column": 26, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, @@ -22155,25 +22393,77 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 22, "line": 1, }, "start": Object { - "column": 17, + "column": 21, "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + }, "range": Array [ - 17, - 18, + 21, + 22, + ], + "type": "TSTypeParameter", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "name": "U", + "range": Array [ + 24, + 25, + ], + "type": "Identifier", + }, + "range": Array [ + 24, + 25, ], "type": "TSTypeParameter", }, ], "range": Array [ - 16, - 19, + 20, + 26, ], "type": "TSTypeParameterDeclaration", }, @@ -22190,11 +22480,9 @@ Object { }, "range": Array [ 0, - 24, + 31, ], - "source": null, - "specifiers": Array [], - "type": "ExportNamedDeclaration", + "type": "ExportDefaultDeclaration", }, ], "comments": Array [], @@ -22210,7 +22498,7 @@ Object { }, "range": Array [ 0, - 25, + 32, ], "sourceType": "module", "tokens": Array [ @@ -22235,7 +22523,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 12, + "column": 14, "line": 1, }, "start": Object { @@ -22245,43 +22533,43 @@ Object { }, "range": Array [ 7, - 12, + 14, ], "type": "Keyword", - "value": "class", + "value": "default", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 20, "line": 1, }, "start": Object { - "column": 13, + "column": 15, "line": 1, }, }, "range": Array [ - 13, - 16, + 15, + 20, ], - "type": "Identifier", - "value": "Foo", + "type": "Keyword", + "value": "class", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 21, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 17, + 20, + 21, ], "type": "Punctuator", "value": "<", @@ -22289,17 +22577,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 22, "line": 1, }, "start": Object { - "column": 17, + "column": 21, "line": 1, }, }, "range": Array [ - 17, - 18, + 21, + 22, ], "type": "Identifier", "value": "T", @@ -22307,17 +22595,53 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 23, "line": 1, }, "start": Object { - "column": 18, + "column": 22, "line": 1, }, }, "range": Array [ - 18, - 19, + 22, + 23, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Identifier", + "value": "U", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, ], "type": "Punctuator", "value": ">", @@ -22325,17 +22649,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 21, + "column": 28, "line": 1, }, "start": Object { - "column": 20, + "column": 27, "line": 1, }, }, "range": Array [ - 20, - 21, + 27, + 28, ], "type": "Punctuator", "value": "{", @@ -22352,8 +22676,8 @@ Object { }, }, "range": Array [ - 23, - 24, + 30, + 31, ], "type": "Punctuator", "value": "}", @@ -22363,7 +22687,7 @@ Object { } `; -exports[`typescript fixtures/basics/export-named-class-with-multiple-generics.src 1`] = ` +exports[`typescript fixtures/basics/export-named-class-with-generic.src 1`] = ` Object { "body": Array [ Object { @@ -22376,13 +22700,13 @@ Object { "line": 3, }, "start": Object { - "column": 23, + "column": 20, "line": 1, }, }, "range": Array [ - 23, - 27, + 20, + 24, ], "type": "ClassBody", }, @@ -22416,14 +22740,14 @@ Object { }, "range": Array [ 7, - 27, + 24, ], "superClass": null, "type": "ClassDeclaration", "typeParameters": Object { "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 1, }, "start": Object { @@ -22443,35 +22767,34 @@ Object { "line": 1, }, }, - "name": "T", - "range": Array [ - 17, - 18, - ], - "type": "TSTypeParameter", - }, - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, + "name": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, }, + "name": "T", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", }, - "name": "U", "range": Array [ - 20, - 21, + 17, + 18, ], "type": "TSTypeParameter", }, ], "range": Array [ 16, - 22, + 19, ], "type": "TSTypeParameterDeclaration", }, @@ -22488,7 +22811,7 @@ Object { }, "range": Array [ 0, - 27, + 24, ], "source": null, "specifiers": Array [], @@ -22508,7 +22831,339 @@ Object { }, "range": Array [ 0, - 28, + 25, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Keyword", + "value": "export", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "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": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/export-named-class-with-multiple-generics.src 1`] = ` +Object { + "body": Array [ + Object { + "declaration": Object { + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 27, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 13, + 16, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 27, + ], + "superClass": null, + "type": "ClassDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + "range": Array [ + 17, + 18, + ], + "type": "TSTypeParameter", + }, + 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": "U", + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + }, + "range": Array [ + 20, + 21, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 16, + 22, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "source": null, + "specifiers": Array [], + "type": "ExportNamedDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, ], "sourceType": "module", "tokens": Array [ @@ -23053,112 +23708,92 @@ Object { "body": Array [ Object { "declaration": Object { - "declarations": Array [ - Object { - "id": 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", + }, + "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": 21, + "column": 30, "line": 1, }, "start": Object { - "column": 12, + "column": 24, "line": 1, }, }, - "name": "TestAlias", "range": Array [ - 12, - 21, + 24, + 30, ], - "type": "Identifier", + "type": "TSStringKeyword", }, - "init": Object { + Object { "loc": Object { "end": Object { "column": 39, "line": 1, }, "start": Object { - "column": 24, + "column": 33, "line": 1, }, }, "range": Array [ - 24, + 33, 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", - }, - ], - }, - "loc": Object { - "end": Object { - "column": 40, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "type": "TSNumberKeyword", }, - "range": Array [ - 12, - 40, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 40, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, - }, + ], }, - "range": Array [ - 7, - 40, - ], - "type": "VariableDeclaration", }, "loc": Object { "end": Object { @@ -23350,133 +23985,24 @@ Object { "body": Array [ Object { "declaration": Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "name": "TestClassProps", - "range": Array [ - 12, - 26, - ], - "type": "Identifier", + "id": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, }, - "init": 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", - }, - "loc": Object { - "end": Object { - "column": 17, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 35, - 48, - ], - "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", - }, - }, - }, - ], - "range": Array [ - 29, - 50, - ], - "type": "TSTypeLiteral", - }, - "loc": Object { - "end": Object { - "column": 2, - "line": 3, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "start": Object { + "column": 12, + "line": 1, }, - "range": Array [ - 12, - 51, - ], - "type": "VariableDeclarator", }, - ], - "kind": "type", + "name": "TestClassProps", + "range": Array [ + 12, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { "column": 2, @@ -23491,7 +24017,96 @@ Object { 7, 51, ], - "type": "VariableDeclaration", + "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", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 35, + 48, + ], + "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", + }, + }, + }, + ], + "range": Array [ + 29, + 50, + ], + "type": "TSTypeLiteral", + }, }, "loc": Object { "end": Object { @@ -23719,165 +24334,144 @@ Object { "body": Array [ Object { "declaration": Object { - "declarations": Array [ - 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", + "id": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, }, - "init": Object { + }, + "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": 46, + "column": 37, "line": 1, }, "start": Object { - "column": 27, + "column": 28, "line": 1, }, }, - "parameters": 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", - }, - }, - }, - ], + "name": "a", "range": Array [ - 27, - 46, + 28, + 37, ], - "type": "TSFunctionType", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 46, + "column": 37, "line": 1, }, "start": Object { - "column": 40, + "column": 29, "line": 1, }, }, "range": Array [ - 40, - 46, + 29, + 37, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 46, + "column": 37, "line": 1, }, "start": Object { - "column": 42, + "column": 31, "line": 1, }, }, "range": Array [ - 42, - 46, + 31, + 37, ], - "type": "TSVoidKeyword", + "type": "TSNumberKeyword", }, }, - "typeParameters": null, }, + ], + "range": Array [ + 27, + 46, + ], + "returnType": Object { "loc": Object { "end": Object { - "column": 47, + "column": 46, "line": 1, }, "start": Object { - "column": 12, + "column": 39, "line": 1, }, }, "range": Array [ - 12, - 47, + 39, + 46, ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 47, - "line": 1, - }, - "start": Object { - "column": 7, - "line": 1, + "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", }, - "range": Array [ - 7, - 47, - ], - "type": "VariableDeclaration", }, "loc": Object { "end": Object { @@ -26170,7 +26764,24 @@ Object { "line": 1, }, }, - "name": "X", + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "X", + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + }, "range": Array [ 11, 12, @@ -26596,7 +27207,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 28, + 29, + ], + "type": "Identifier", + }, "range": Array [ 28, 29, @@ -27074,7 +27702,24 @@ Object { "line": 1, }, }, - "name": "X", + "name": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "X", + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + }, "range": Array [ 11, 23, @@ -28164,7 +28809,7 @@ Object { "argument": Object { "loc": Object { "end": Object { - "column": 69, + "column": 55, "line": 1, }, "start": Object { @@ -28175,9 +28820,41 @@ Object { "name": "args", "range": Array [ 51, - 69, + 55, ], "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 69, + "line": 1, + }, + "start": Object { + "column": 48, + "line": 1, + }, + }, + "range": Array [ + 48, + 69, + ], + "type": "RestElement", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 69, + "line": 1, + }, + "start": Object { + "column": 55, + "line": 1, + }, + }, + "range": Array [ + 55, + 69, + ], + "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -28185,19 +28862,19 @@ Object { "line": 1, }, "start": Object { - "column": 55, + "column": 56, "line": 1, }, }, "range": Array [ - 55, + 56, 69, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { - "column": 69, + "column": 61, "line": 1, }, "start": Object { @@ -28205,83 +28882,51 @@ Object { "line": 1, }, }, + "name": "Array", "range": Array [ 56, - 69, + 61, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 61, - "line": 1, - }, - "start": Object { - "column": 56, - "line": 1, - }, + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 69, + "line": 1, }, - "name": "Array", - "range": Array [ - 56, - 61, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 69, - "line": 1, - }, - "start": Object { - "column": 61, - "line": 1, - }, + "start": Object { + "column": 61, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 68, - "line": 1, - }, - "start": Object { - "column": 62, - "line": 1, - }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 68, + "line": 1, + }, + "start": Object { + "column": 62, + "line": 1, }, - "range": Array [ - 62, - 68, - ], - "type": "TSStringKeyword", }, - ], - "range": Array [ - 61, - 69, - ], - "type": "TSTypeParameterInstantiation", - }, + "range": Array [ + 62, + 68, + ], + "type": "TSStringKeyword", + }, + ], + "range": Array [ + 61, + 69, + ], + "type": "TSTypeParameterInstantiation", }, }, }, - "loc": Object { - "end": Object { - "column": 69, - "line": 1, - }, - "start": Object { - "column": 48, - "line": 1, - }, - }, - "range": Array [ - 48, - 69, - ], - "type": "RestElement", }, ], "range": Array [ @@ -28855,296 +29500,256 @@ exports[`typescript fixtures/basics/import-type.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "A", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, }, - "init": Object { - "isTypeOf": true, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "A", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "isTypeOf": true, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "parameter": Object { + "literal": Object { "loc": Object { "end": Object { - "column": 27, + "column": 26, "line": 1, }, "start": Object { - "column": 9, + "column": 23, "line": 1, }, }, - "parameter": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 26, - ], - "raw": "'A'", - "type": "Literal", - "value": "A", - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 26, - ], - "type": "TSLiteralType", - }, - "qualifier": null, "range": Array [ - 9, - 27, + 23, + 26, ], - "type": "TSImportType", - "typeParameters": null, + "raw": "'A'", + "type": "Literal", + "value": "A", }, "loc": Object { "end": Object { - "column": 28, + "column": 26, "line": 1, }, "start": Object { - "column": 5, + "column": 23, "line": 1, }, }, "range": Array [ - 5, - 28, + 23, + 26, ], - "type": "VariableDeclarator", + "type": "TSLiteralType", }, - ], - "kind": "type", + "qualifier": null, + "range": Array [ + 9, + 27, + ], + "type": "TSImportType", + "typeParameters": null, + }, + }, + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "name": "B", + "range": Array [ + 34, + 35, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 28, - "line": 1, + "column": 26, + "line": 2, }, "start": Object { "column": 0, - "line": 1, + "line": 2, }, }, "range": Array [ - 0, - 28, + 29, + 55, ], - "type": "VariableDeclaration", - }, - Object { - "declarations": Array [ - Object { - "id": Object { + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "isTypeOf": false, + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "parameter": Object { + "literal": Object { "loc": Object { "end": Object { - "column": 6, + "column": 19, "line": 2, }, "start": Object { - "column": 5, + "column": 16, "line": 2, }, }, - "name": "B", "range": Array [ - 34, - 35, + 45, + 48, ], - "type": "Identifier", + "raw": "\\"B\\"", + "type": "Literal", + "value": "B", }, - "init": Object { - "isTypeOf": false, - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, + "loc": Object { + "end": Object { + "column": 19, + "line": 2, }, - "parameter": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 45, - 48, - ], - "raw": "\\"B\\"", - "type": "Literal", - "value": "B", - }, - "loc": Object { - "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "range": Array [ - 45, - 48, - ], - "type": "TSLiteralType", + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 45, + 48, + ], + "type": "TSLiteralType", + }, + "qualifier": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 21, + "line": 2, + }, + }, + "name": "X", + "range": Array [ + 50, + 51, + ], + "type": "Identifier", + }, + "range": Array [ + 38, + 54, + ], + "type": "TSImportType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 22, + "line": 2, }, - "qualifier": Object { + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 22, + "column": 24, "line": 2, }, "start": Object { - "column": 21, + "column": 23, "line": 2, }, }, - "name": "X", "range": Array [ - 50, - 51, + 52, + 53, ], - "type": "Identifier", - }, - "range": Array [ - 38, - 54, - ], - "type": "TSImportType", - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 2, - }, - "start": Object { - "column": 22, - "line": 2, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 2, - }, - "start": Object { - "column": 23, - "line": 2, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, }, - "range": Array [ - 52, - 53, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 2, - }, - "start": Object { - "column": 23, - "line": 2, - }, - }, - "name": "Y", - "range": Array [ - 52, - 53, - ], - "type": "Identifier", + "start": Object { + "column": 23, + "line": 2, }, }, - ], - "range": Array [ - 51, - 54, - ], - "type": "TSTypeParameterInstantiation", - }, - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 5, - "line": 2, + "name": "Y", + "range": Array [ + 52, + 53, + ], + "type": "Identifier", + }, }, - }, + ], "range": Array [ - 34, - 55, + 51, + 54, ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 2, + "type": "TSTypeParameterInstantiation", }, }, - "range": Array [ - 29, - 55, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -29569,221 +30174,201 @@ exports[`typescript fixtures/basics/import-type-with-type-parameters-in-type-ref Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "X", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 29, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, }, - "name": "X", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", }, - "init": Object { - "loc": Object { - "end": Object { - "column": 29, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, + "name": "A", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, }, - "range": Array [ - 9, - 29, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "name": "A", - "range": Array [ - 9, - 10, - ], - "type": "Identifier", + "start": Object { + "column": 10, + "line": 1, }, - "typeParameters": Object { + }, + "params": Array [ + Object { + "isTypeOf": false, "loc": Object { "end": Object { - "column": 29, + "column": 28, "line": 1, }, "start": Object { - "column": 10, + "column": 11, "line": 1, }, }, - "params": Array [ - Object { - "isTypeOf": false, + "parameter": Object { + "literal": Object { "loc": Object { "end": Object { - "column": 28, + "column": 20, "line": 1, }, "start": Object { - "column": 11, + "column": 18, "line": 1, }, }, - "parameter": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 20, - ], - "raw": "\\"\\"", - "type": "Literal", - "value": "", - }, - "loc": Object { - "end": Object { - "column": 20, - "line": 1, - }, - "start": Object { - "column": 18, - "line": 1, - }, - }, - "range": Array [ - 18, - 20, - ], - "type": "TSLiteralType", - }, - "qualifier": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "name": "B", - "range": Array [ - 22, - 23, - ], - "type": "Identifier", - }, "range": Array [ - 11, - 28, + 18, + 20, ], - "type": "TSImportType", - "typeParameters": Object { + "raw": "\\"\\"", + "type": "Literal", + "value": "", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 20, + ], + "type": "TSLiteralType", + }, + "qualifier": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "B", + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + }, + "range": Array [ + 11, + 28, + ], + "type": "TSImportType", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 28, + "column": 27, "line": 1, }, "start": Object { - "column": 23, + "column": 24, "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "range": Array [ - 24, - 27, - ], - "type": "TSAnyKeyword", - }, - ], "range": Array [ - 23, - 28, + 24, + 27, ], - "type": "TSTypeParameterInstantiation", + "type": "TSAnyKeyword", }, - }, - ], - "range": Array [ - 10, - 29, - ], - "type": "TSTypeParameterInstantiation", - }, - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + ], + "range": Array [ + 23, + 28, + ], + "type": "TSTypeParameterInstantiation", + }, }, - }, + ], "range": Array [ - 5, - 30, + 10, + 29, ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "TSTypeParameterInstantiation", }, }, - "range": Array [ - 0, - 30, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -30100,7 +30685,6 @@ exports[`typescript fixtures/basics/interface-extends.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -30119,9 +30703,9 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [ + "extends": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 25, @@ -30325,7 +30909,6 @@ exports[`typescript fixtures/basics/interface-extends-multiple.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -30344,9 +30927,9 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [ + "extends": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 25, @@ -30381,7 +30964,7 @@ Object { "type": "TSInterfaceHeritage", }, Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 29, @@ -30621,7 +31204,6 @@ exports[`typescript fixtures/basics/interface-type-parameters.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -30640,7 +31222,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -30697,7 +31278,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, "range": Array [ 14, 15, @@ -30865,7 +31463,6 @@ exports[`typescript fixtures/basics/interface-with-all-property-types.src 1`] = Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -31151,39 +31748,34 @@ Object { }, }, Object { - "index": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 6, - }, - "start": Object { - "column": 5, - "line": 6, - }, + "loc": Object { + "end": Object { + "column": 26, + "line": 6, }, - "name": "eee", - "range": Array [ - 95, - 106, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 6, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 16, "line": 6, }, "start": Object { - "column": 8, + "column": 5, "line": 6, }, }, + "name": "eee", "range": Array [ - 98, + 95, 106, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -31191,33 +31783,39 @@ Object { "line": 6, }, "start": Object { - "column": 10, + "column": 8, "line": 6, }, }, "range": Array [ - 100, + 98, 106, ], - "type": "TSNumberKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 6, + }, + "start": Object { + "column": 10, + "line": 6, + }, + }, + "range": Array [ + 100, + 106, + ], + "type": "TSNumberKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 26, - "line": 6, - }, - "start": Object { - "column": 4, - "line": 6, - }, - }, + ], "range": Array [ 94, 116, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -31255,40 +31853,35 @@ Object { }, }, Object { - "index": Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 7, - }, - "start": Object { - "column": 5, - "line": 7, - }, + "loc": Object { + "end": Object { + "column": 27, + "line": 7, }, - "name": "fff", - "optional": true, - "range": Array [ - 122, - 134, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 7, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 17, "line": 7, }, "start": Object { - "column": 9, + "column": 5, "line": 7, }, }, + "name": "fff", + "optional": true, "range": Array [ - 126, + 122, 134, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -31296,33 +31889,39 @@ Object { "line": 7, }, "start": Object { - "column": 11, + "column": 9, "line": 7, }, }, "range": Array [ - 128, + 126, 134, ], - "type": "TSNumberKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 7, + }, + "start": Object { + "column": 11, + "line": 7, + }, + }, + "range": Array [ + 128, + 134, + ], + "type": "TSNumberKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 27, - "line": 7, - }, - "start": Object { - "column": 4, - "line": 7, - }, - }, + ], "range": Array [ 121, 144, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -31389,15 +31988,12 @@ Object { "line": 8, }, }, - "optional": false, "params": Array [], "range": Array [ 149, 161, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 15, @@ -31431,6 +32027,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "computed": false, @@ -31523,9 +32120,7 @@ Object { 166, 186, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 23, @@ -31559,6 +32154,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "computed": true, @@ -31651,9 +32247,7 @@ Object { 191, 213, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 25, @@ -31687,6 +32281,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "computed": false, @@ -31718,7 +32313,6 @@ Object { "line": 11, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -31779,9 +32373,7 @@ Object { 218, 240, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 25, @@ -31815,6 +32407,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", "typeParameters": Object { "loc": Object { "end": Object { @@ -31838,7 +32431,24 @@ Object { "line": 11, }, }, - "name": "J", + "name": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 11, + }, + "start": Object { + "column": 8, + "line": 11, + }, + }, + "name": "J", + "range": Array [ + 222, + 223, + ], + "type": "Identifier", + }, "range": Array [ 222, 223, @@ -31907,8 +32517,7 @@ Object { 245, 265, ], - "type": "TSConstructSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 23, @@ -31942,6 +32551,7 @@ Object { "type": "TSStringKeyword", }, }, + "type": "TSConstructSignatureDeclaration", }, Object { "loc": Object { @@ -31997,8 +32607,7 @@ Object { 270, 293, ], - "type": "TSConstructSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 26, @@ -32032,6 +32641,7 @@ Object { "type": "TSStringKeyword", }, }, + "type": "TSConstructSignatureDeclaration", "typeParameters": Object { "loc": Object { "end": Object { @@ -32055,7 +32665,24 @@ Object { "line": 13, }, }, - "name": "F", + "name": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 13, + }, + "start": Object { + "column": 9, + "line": 13, + }, + }, + "name": "F", + "range": Array [ + 275, + 276, + ], + "type": "Identifier", + }, "range": Array [ 275, 276, @@ -32087,7 +32714,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -34165,7 +34791,6 @@ exports[`typescript fixtures/basics/interface-with-construct-signature-with-para Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -34257,8 +34882,7 @@ Object { 21, 47, ], - "type": "TSConstructSignature", - "typeAnnotation": null, + "type": "TSConstructSignatureDeclaration", }, ], "loc": Object { @@ -34277,7 +34901,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -34573,7 +35196,6 @@ exports[`typescript fixtures/basics/interface-with-extends-type-parameters.src 1 Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -34592,9 +35214,9 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [ + "extends": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 28, @@ -34739,7 +35361,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, "range": Array [ 14, 15, @@ -34997,7 +35636,6 @@ exports[`typescript fixtures/basics/interface-with-generic.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -35016,7 +35654,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -35073,7 +35710,24 @@ Object { "line": 1, }, }, - "name": "T", + "name": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 15, + 16, + ], + "type": "Identifier", + }, "range": Array [ 15, 16, @@ -35241,7 +35895,6 @@ exports[`typescript fixtures/basics/interface-with-jsdoc.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -35274,7 +35927,6 @@ Object { "line": 6, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -35299,9 +35951,7 @@ Object { 76, 85, ], - "static": false, "type": "TSMethodSignature", - "typeAnnotation": null, }, ], "loc": Object { @@ -35320,7 +35970,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -35566,7 +36215,6 @@ exports[`typescript fixtures/basics/interface-with-optional-properties.src 1`] = Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -35804,9 +36452,7 @@ Object { 49, 79, ], - "static": false, "type": "TSMethodSignature", - "typeAnnotation": null, }, ], "loc": Object { @@ -35825,7 +36471,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -36355,7 +37000,6 @@ exports[`typescript fixtures/basics/interface-without-type-annotation.src 1`] = Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -36411,7 +37055,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -36581,97 +37224,24 @@ exports[`typescript fixtures/basics/keyof-operator.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "x", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", - }, - "init": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "operator": "keyof", - "range": Array [ - 9, - 18, - ], - "type": "TSTypeOperator", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "range": Array [ - 15, - 18, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "name": "foo", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", - }, - }, + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 19, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, + "start": Object { + "column": 5, + "line": 1, }, - "range": Array [ - 5, - 19, - ], - "type": "VariableDeclarator", }, - ], - "kind": "type", + "name": "x", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { "column": 19, @@ -36686,7 +37256,60 @@ Object { 0, 19, ], - "type": "VariableDeclaration", + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "operator": "keyof", + "range": Array [ + 9, + 18, + ], + "type": "TSTypeOperator", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 18, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + }, + }, }, ], "comments": Array [], @@ -40623,30 +41246,60 @@ exports[`typescript fixtures/basics/type-alias-declaration.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Result", - "range": Array [ - 5, - 11, - ], - "type": "Identifier", + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, }, - "init": Object { + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Result", + "range": Array [ + 5, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 37, + ], + "type": "TSUnionType", + "types": Array [ + Object { "loc": Object { "end": Object { - "column": 37, + "column": 27, "line": 1, }, "start": Object { @@ -40656,206 +41309,173 @@ Object { }, "range": Array [ 17, - 37, + 27, ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 17, - "line": 1, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, }, - "range": Array [ - 17, - 27, - ], - "type": "TSTypeReference", - "typeName": Object { + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "Success", + "range": Array [ + 17, + 24, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 24, + "column": 26, "line": 1, }, "start": Object { - "column": 17, + "column": 25, "line": 1, }, }, - "name": "Success", "range": Array [ - 17, - 24, + 25, + 26, ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 24, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, }, - "range": Array [ - 25, - 26, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 25, - 26, - ], - "type": "Identifier", + "start": Object { + "column": 25, + "line": 1, }, }, - ], - "range": Array [ - 24, - 27, - ], - "type": "TSTypeParameterInstantiation", + "name": "T", + "range": Array [ + 25, + 26, + ], + "type": "Identifier", + }, }, + ], + "range": Array [ + 24, + 27, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, }, - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 37, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, }, - "range": Array [ - 30, - 37, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 30, - "line": 1, - }, - }, - "name": "Failure", - "range": Array [ - 30, - 37, - ], - "type": "Identifier", + "start": Object { + "column": 30, + "line": 1, }, }, - ], - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + "name": "Failure", + "range": Array [ + 30, + 37, + ], + "type": "Identifier", }, }, - "range": Array [ - 5, - 37, - ], - "type": "VariableDeclarator", - "typeParameters": Object { + ], + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 14, + "column": 13, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 13, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, }, - "name": "T", - "range": Array [ - 12, - 13, - ], - "type": "TSTypeParameter", }, - ], + "name": "T", + "range": Array [ + 12, + 13, + ], + "type": "Identifier", + }, "range": Array [ - 11, - 14, + 12, + 13, ], - "type": "TSTypeParameterDeclaration", + "type": "TSTypeParameter", }, - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, + ], + "range": Array [ + 11, + 14, + ], + "type": "TSTypeParameterDeclaration", }, - "range": Array [ - 0, - 37, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -41100,30 +41720,60 @@ exports[`typescript fixtures/basics/type-alias-declaration-with-constrained-type Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 11, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Result", - "range": Array [ - 5, - 11, - ], - "type": "Identifier", + "id": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, }, - "init": Object { + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Result", + "range": Array [ + 5, + 11, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 48, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 48, + ], + "type": "TSUnionType", + "types": Array [ + Object { "loc": Object { "end": Object { - "column": 48, + "column": 38, "line": 1, }, "start": Object { @@ -41133,224 +41783,191 @@ Object { }, "range": Array [ 28, - 48, + 38, ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 28, - "line": 1, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, }, - "range": Array [ - 28, - 38, - ], - "type": "TSTypeReference", - "typeName": Object { + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "Success", + "range": Array [ + 28, + 35, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "params": Array [ + Object { "loc": Object { "end": Object { - "column": 35, + "column": 37, "line": 1, }, "start": Object { - "column": 28, + "column": 36, "line": 1, }, }, - "name": "Success", "range": Array [ - 28, - 35, + 36, + 37, ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 35, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, }, - "range": Array [ - 36, - 37, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 37, - "line": 1, - }, - "start": Object { - "column": 36, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 36, - 37, - ], - "type": "Identifier", + "start": Object { + "column": 36, + "line": 1, }, }, - ], - "range": Array [ - 35, - 38, - ], - "type": "TSTypeParameterInstantiation", + "name": "T", + "range": Array [ + 36, + 37, + ], + "type": "Identifier", + }, }, + ], + "range": Array [ + 35, + 38, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, }, - Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 48, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, }, - "range": Array [ - 41, - 48, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, - }, - "name": "Failure", - "range": Array [ - 41, - 48, - ], - "type": "Identifier", + "start": Object { + "column": 41, + "line": 1, }, }, - ], - }, - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + "name": "Failure", + "range": Array [ + 41, + 48, + ], + "type": "Identifier", }, }, - "range": Array [ - 5, - 48, - ], - "type": "VariableDeclarator", - "typeParameters": Object { + ], + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "params": Array [ + Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "members": Array [], + "range": Array [ + 22, + 24, + ], + "type": "TSTypeLiteral", + }, "loc": Object { "end": Object { - "column": 25, + "column": 24, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, - "params": Array [ - Object { - "constraint": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 22, - "line": 1, - }, - }, - "members": Array [], - "range": Array [ - 22, - 24, - ], - "type": "TSTypeLiteral", + "name": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "start": Object { + "column": 12, + "line": 1, }, - "name": "T", - "range": Array [ - 12, - 24, - ], - "type": "TSTypeParameter", }, - ], + "name": "T", + "range": Array [ + 12, + 13, + ], + "type": "Identifier", + }, "range": Array [ - 11, - 25, + 12, + 24, ], - "type": "TSTypeParameterDeclaration", + "type": "TSTypeParameter", }, - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, + ], + "range": Array [ + 11, + 25, + ], + "type": "TSTypeParameterDeclaration", }, - "range": Array [ - 0, - 48, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -41649,184 +42266,164 @@ exports[`typescript fixtures/basics/type-alias-object-without-annotation.src 1`] Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, }, + "name": "bar", + "range": Array [ + 12, + 15, + ], + "type": "Identifier", }, - "name": "foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", - }, - "init": Object { "loc": Object { "end": Object { - "column": 29, + "column": 24, "line": 1, }, "start": Object { - "column": 11, + "column": 12, "line": 1, }, }, - "members": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "name": "bar", - "range": Array [ - 12, - 15, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "range": Array [ + 12, + 24, + ], + "type": "TSPropertySignature", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, }, - "range": Array [ - 12, - 24, - ], - "type": "TSPropertySignature", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, - }, - }, - "range": Array [ - 15, - 23, - ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 17, - "line": 1, - }, - }, - "range": Array [ - 17, - 23, - ], - "type": "TSStringKeyword", - }, + "start": Object { + "column": 15, + "line": 1, }, }, - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "name": "baz", - "range": Array [ - 25, - 28, - ], - "type": "Identifier", - }, + "range": Array [ + 15, + 23, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 28, + "column": 23, "line": 1, }, "start": Object { - "column": 25, + "column": 17, "line": 1, }, }, "range": Array [ - 25, - 28, + 17, + 23, ], - "type": "TSPropertySignature", + "type": "TSStringKeyword", }, - ], - "range": Array [ - 11, - 29, - ], - "type": "TSTypeLiteral", + }, }, - "loc": Object { - "end": Object { - "column": 30, - "line": 1, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "name": "baz", + "range": Array [ + 25, + 28, + ], + "type": "Identifier", }, - "start": Object { - "column": 5, - "line": 1, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, }, + "range": Array [ + 25, + 28, + ], + "type": "TSPropertySignature", }, - "range": Array [ - 5, - 30, - ], - "type": "VariableDeclarator", - }, - ], - "kind": "type", - "loc": Object { - "end": Object { - "column": 30, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, + ], + "range": Array [ + 11, + 29, + ], + "type": "TSTypeLiteral", }, - "range": Array [ - 0, - 30, - ], - "type": "VariableDeclaration", }, ], "comments": Array [], @@ -42876,7 +43473,24 @@ Object { "line": 2, }, }, - "name": "A", + "name": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "A", + "range": Array [ + 68, + 69, + ], + "type": "Identifier", + }, "range": Array [ 68, 69, @@ -43005,7 +43619,24 @@ Object { "line": 3, }, }, - "name": "A", + "name": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 3, + }, + "start": Object { + "column": 24, + "line": 3, + }, + }, + "name": "A", + "range": Array [ + 112, + 113, + ], + "type": "Identifier", + }, "range": Array [ 112, 129, @@ -44137,7 +44768,6 @@ exports[`typescript fixtures/basics/typed-this.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -44170,7 +44800,6 @@ Object { "line": 2, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -44216,7 +44845,7 @@ Object { "line": 2, }, }, - "parameters": Array [ + "params": Array [ Object { "loc": Object { "end": Object { @@ -44344,20 +44973,19 @@ Object { 49, 79, ], - "type": "TSFunctionType", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 57, "line": 2, }, "start": Object { - "column": 51, + "column": 50, "line": 2, }, }, "range": Array [ - 73, + 72, 79, ], "type": "TSTypeAnnotation", @@ -44379,7 +45007,7 @@ Object { "type": "TSVoidKeyword", }, }, - "typeParameters": null, + "type": "TSFunctionType", }, }, }, @@ -44388,9 +45016,7 @@ Object { 23, 87, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 64, @@ -44424,6 +45050,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, ], "loc": Object { @@ -44442,7 +45069,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -44918,79 +45544,24 @@ exports[`typescript fixtures/basics/unique-symbol.src 1`] = ` Object { "body": Array [ Object { - "declarations": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 6, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "A", - "range": Array [ - 5, - 6, - ], - "type": "Identifier", - }, - "init": Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "operator": "unique", - "range": Array [ - 9, - 22, - ], - "type": "TSTypeOperator", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 22, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "range": Array [ - 16, - 22, - ], - "type": "TSSymbolKeyword", - }, + "id": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, }, - "loc": Object { - "end": Object { - "column": 23, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, + "start": Object { + "column": 5, + "line": 1, }, - "range": Array [ - 5, - 23, - ], - "type": "VariableDeclarator", }, - ], - "kind": "type", + "name": "A", + "range": Array [ + 5, + 6, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { "column": 23, @@ -45005,7 +45576,42 @@ Object { 0, 23, ], - "type": "VariableDeclaration", + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "operator": "unique", + "range": Array [ + 9, + 22, + ], + "type": "TSTypeOperator", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "TSSymbolKeyword", + }, + }, }, ], "comments": Array [], @@ -58128,7 +58734,7 @@ Object { }, "implements": Array [ Object { - "id": Object { + "expression": Object { "loc": Object { "end": Object { "column": 32, @@ -58160,7 +58766,7 @@ Object { 29, 32, ], - "type": "ClassImplements", + "type": "TSClassImplements", }, ], "loc": Object { @@ -58764,7 +59370,6 @@ exports[`typescript fixtures/errorRecovery/decorator-on-interface-declaration.sr Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -58838,7 +59443,6 @@ Object { "type": "Decorator", }, ], - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -59722,7 +60326,6 @@ exports[`typescript fixtures/errorRecovery/interface-empty-extends.src 1`] = ` Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [], "loc": Object { @@ -59741,7 +60344,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -59893,7 +60495,6 @@ exports[`typescript fixtures/errorRecovery/interface-property-modifiers.src 1`] Object { "body": Array [ Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -60413,39 +61014,34 @@ Object { }, Object { "accessibility": "public", - "index": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 10, - }, - "start": Object { - "column": 12, - "line": 10, - }, + "loc": Object { + "end": Object { + "column": 33, + "line": 10, }, - "name": "baz", - "range": Array [ - 190, - 201, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 10, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 23, "line": 10, }, "start": Object { - "column": 15, + "column": 12, "line": 10, }, }, + "name": "baz", "range": Array [ - 193, + 190, 201, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60453,33 +61049,39 @@ Object { "line": 10, }, "start": Object { - "column": 17, + "column": 15, "line": 10, }, }, "range": Array [ - 195, + 193, 201, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 10, + }, + "start": Object { + "column": 17, + "line": 10, + }, + }, + "range": Array [ + 195, + 201, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 10, - }, - "start": Object { - "column": 4, - "line": 10, - }, - }, + ], "range": Array [ 182, 211, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -60518,39 +61120,34 @@ Object { }, Object { "accessibility": "private", - "index": Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 11, - }, - "start": Object { - "column": 13, - "line": 11, - }, + "loc": Object { + "end": Object { + "column": 34, + "line": 11, }, - "name": "baz", - "range": Array [ - 225, - 236, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 11, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 24, "line": 11, }, "start": Object { - "column": 16, + "column": 13, "line": 11, }, }, + "name": "baz", "range": Array [ - 228, + 225, 236, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60558,33 +61155,39 @@ Object { "line": 11, }, "start": Object { - "column": 18, + "column": 16, "line": 11, }, }, "range": Array [ - 230, + 228, 236, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 11, + }, + "start": Object { + "column": 18, + "line": 11, + }, + }, + "range": Array [ + 230, + 236, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 34, - "line": 11, - }, - "start": Object { - "column": 4, - "line": 11, - }, - }, + ], "range": Array [ 216, 246, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -60623,39 +61226,34 @@ Object { }, Object { "accessibility": "protected", - "index": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 12, - }, - "start": Object { - "column": 15, - "line": 12, - }, + "loc": Object { + "end": Object { + "column": 36, + "line": 12, }, - "name": "baz", - "range": Array [ - 262, - 273, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 12, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 26, "line": 12, }, "start": Object { - "column": 18, + "column": 15, "line": 12, }, }, + "name": "baz", "range": Array [ - 265, + 262, 273, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60663,33 +61261,39 @@ Object { "line": 12, }, "start": Object { - "column": 20, + "column": 18, "line": 12, }, }, "range": Array [ - 267, + 265, 273, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 12, + }, + "start": Object { + "column": 20, + "line": 12, + }, + }, + "range": Array [ + 267, + 273, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 12, - }, - "start": Object { - "column": 4, - "line": 12, - }, - }, + ], "range": Array [ 251, 283, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -60727,39 +61331,34 @@ Object { }, }, Object { - "index": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 13, - }, - "start": Object { - "column": 12, - "line": 13, - }, + "loc": Object { + "end": Object { + "column": 33, + "line": 13, }, - "name": "baz", - "range": Array [ - 296, - 307, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 13, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 23, "line": 13, }, "start": Object { - "column": 15, + "column": 12, "line": 13, }, }, + "name": "baz", "range": Array [ - 299, + 296, 307, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60767,28 +61366,35 @@ Object { "line": 13, }, "start": Object { - "column": 17, + "column": 15, "line": 13, }, }, "range": Array [ - 301, + 299, 307, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 13, + }, + "start": Object { + "column": 17, + "line": 13, + }, + }, + "range": Array [ + 301, + 307, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 13, - }, - "start": Object { - "column": 4, - "line": 13, - }, - }, + ], "range": Array [ 288, 317, @@ -60832,39 +61438,34 @@ Object { }, Object { "export": true, - "index": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 14, - }, - "start": Object { - "column": 12, - "line": 14, - }, + "loc": Object { + "end": Object { + "column": 33, + "line": 14, }, - "name": "baz", - "range": Array [ - 330, - 341, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 14, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 23, "line": 14, }, "start": Object { - "column": 15, + "column": 12, "line": 14, }, }, + "name": "baz", "range": Array [ - 333, + 330, 341, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60872,33 +61473,39 @@ Object { "line": 14, }, "start": Object { - "column": 17, + "column": 15, "line": 14, }, }, "range": Array [ - 335, + 333, 341, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 14, + }, + "start": Object { + "column": 17, + "line": 14, + }, + }, + "range": Array [ + 335, + 341, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 14, - }, - "start": Object { - "column": 4, - "line": 14, - }, - }, + ], "range": Array [ 322, 351, ], - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -60936,39 +61543,34 @@ Object { }, }, Object { - "index": Object { - "loc": Object { - "end": Object { - "column": 25, - "line": 15, - }, - "start": Object { - "column": 14, - "line": 15, - }, + "loc": Object { + "end": Object { + "column": 35, + "line": 15, }, - "name": "baz", - "range": Array [ - 366, - 377, - ], - "type": "Identifier", - "typeAnnotation": Object { + "start": Object { + "column": 4, + "line": 15, + }, + }, + "parameters": Array [ + Object { "loc": Object { "end": Object { "column": 25, "line": 15, }, "start": Object { - "column": 17, + "column": 14, "line": 15, }, }, + "name": "baz", "range": Array [ - 369, + 366, 377, ], - "type": "TSTypeAnnotation", + "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { @@ -60976,34 +61578,40 @@ Object { "line": 15, }, "start": Object { - "column": 19, + "column": 17, "line": 15, }, }, "range": Array [ - 371, + 369, 377, ], - "type": "TSStringKeyword", + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 15, + }, + "start": Object { + "column": 19, + "line": 15, + }, + }, + "range": Array [ + 371, + 377, + ], + "type": "TSStringKeyword", + }, }, }, - }, - "loc": Object { - "end": Object { - "column": 35, - "line": 15, - }, - "start": Object { - "column": 4, - "line": 15, - }, - }, + ], "range": Array [ 356, 387, ], "readonly": true, - "static": false, "type": "TSIndexSignature", "typeAnnotation": Object { "loc": Object { @@ -61071,7 +61679,6 @@ Object { "line": 17, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61130,9 +61737,7 @@ Object { 393, 421, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 31, @@ -61166,6 +61771,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "accessibility": "private", @@ -61198,7 +61804,6 @@ Object { "line": 18, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61257,9 +61862,7 @@ Object { 426, 455, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 32, @@ -61293,6 +61896,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "accessibility": "protected", @@ -61325,7 +61929,6 @@ Object { "line": 19, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61384,9 +61987,7 @@ Object { 460, 491, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 34, @@ -61420,6 +62021,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "computed": false, @@ -61451,7 +62053,6 @@ Object { "line": 20, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61510,9 +62111,7 @@ Object { 496, 524, ], - "static": true, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 31, @@ -61546,6 +62145,8 @@ Object { "type": "TSVoidKeyword", }, }, + "static": true, + "type": "TSMethodSignature", }, Object { "computed": false, @@ -61578,7 +62179,6 @@ Object { "line": 21, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61637,9 +62237,7 @@ Object { 529, 557, ], - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 31, @@ -61673,6 +62271,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, Object { "computed": false, @@ -61704,7 +62303,6 @@ Object { "line": 22, }, }, - "optional": false, "params": Array [ Object { "loc": Object { @@ -61764,9 +62362,7 @@ Object { 592, ], "readonly": true, - "static": false, - "type": "TSMethodSignature", - "typeAnnotation": Object { + "returnType": Object { "loc": Object { "end": Object { "column": 33, @@ -61800,6 +62396,7 @@ Object { "type": "TSVoidKeyword", }, }, + "type": "TSMethodSignature", }, ], "loc": Object { @@ -61818,7 +62415,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { @@ -66117,7 +66713,6 @@ Object { Object { "declaration": Object { "async": false, - "body": null, "expression": false, "generator": false, "id": Object { @@ -66294,7 +66889,7 @@ Object { }, }, }, - "type": "TSEmptyBodyFunctionDeclaration", + "type": "TSDeclareFunction", }, "loc": Object { "end": Object { @@ -67954,7 +68549,6 @@ Object { "body": Array [ Object { "declaration": Object { - "abstract": false, "body": Object { "body": Array [ Object { @@ -68044,7 +68638,6 @@ Object { ], "type": "TSInterfaceBody", }, - "heritage": Array [], "id": Object { "loc": Object { "end": Object { diff --git a/visitor-keys.js b/visitor-keys.js index 40a5e49..210a5ac 100644 --- a/visitor-keys.js +++ b/visitor-keys.js @@ -19,10 +19,12 @@ module.exports = Evk.unionWith({ Identifier: ["decorators", "typeAnnotation"], MethodDefinition: ["decorators", "key", "value"], ObjectPattern: ["properties", "typeAnnotation"], + RestElement: ["argument", "typeAnnotation"], NewExpression: ["callee", "typeParameters", "arguments"], CallExpression: ["callee", "typeParameters", "arguments"], // Additional Nodes. + BigIntLiteral: [], ClassProperty: ["decorators", "key", "typeAnnotation", "value"], Decorator: ["expression"], TSAbstractClassProperty: ["decorators", "key", "typeAnnotation", "value"], @@ -31,14 +33,17 @@ module.exports = Evk.unionWith({ TSAbstractMethodDefinition: ["key", "value"], TSAnyKeyword: [], TSArrayType: ["elementType"], + TSAsExpression: ["expression", "typeAnnotation"], TSAsyncKeyword: [], + TSBigIntKeyword: [], TSBooleanKeyword: [], - TSCallSignature: ["typeParameters", "parameters", "typeAnnotation"], - TSConstructSignature: ["typeParameters", "params", "typeAnnotation"], - TSConstructorType: ["typeAnnotation", "parameters"], + TSCallSignatureDeclaration: ["typeParameters", "params", "returnType"], + TSClassImplements: ["expression", "typeParameters"], + TSConditionalType: ["checkType", "extendsType", "trueType", "falseType"], + TSConstructSignatureDeclaration: ["typeParameters", "params", "returnType"], + TSConstructorType: ["typeParameters", "params", "returnType"], + TSDeclareFunction: ["id", "typeParameters", "params", "returnType"], TSDeclareKeyword: [], - TSEmptyBodyDeclareFunction: ["id", "typeParameters", "params", "returnType"], - TSEmptyBodyFunctionDeclaration: ["id", "typeParameters", "params", "returnType"], TSEmptyBodyFunctionExpression: ["id", "typeParameters", "params", "returnType"], TSEnumDeclaration: ["members"], TSEnumMember: ["id", "initializer"], @@ -46,23 +51,29 @@ module.exports = Evk.unionWith({ TSExportKeyword: [], TSExternalModuleReference: ["expression"], TSImportType: ["parameter", "qualifier", "typeParameters"], + TSInferType: ["typeParameter"], TSLiteralType: ["literal"], - TSIndexSignature: ["typeAnnotation", "index"], + TSIntersectionType: ["types"], + TSIndexedAccessType: ["indexType", "objectType"], + TSIndexSignature: ["typeAnnotation", "parameters"], TSInterfaceBody: ["body"], - TSInterfaceDeclaration: ["id", "typeParameters", "heritage", "body"], - TSInterfaceHeritage: ["id", "typeParameters"], - TSImportEqualsDeclaration: ["name", "moduleReference"], - TSFunctionType: ["parameters", "typeAnnotation"], - TSMethodSignature: ["typeAnnotation", "typeParameters", "key", "params"], + TSInterfaceDeclaration: ["id", "typeParameters", "extends", "body"], + TSInterfaceHeritage: ["expression", "typeParameters"], + TSImportEqualsDeclaration: ["id", "moduleReference"], + TSFunctionType: ["typeParameters", "params", "returnType"], + TSMappedType: ["typeParameter"], + TSMethodSignature: ["typeParameters", "key", "params", "returnType"], TSModuleBlock: ["body"], TSModuleDeclaration: ["id", "body"], - TSNamespaceFunctionDeclaration: [], + TSNamespaceExportDeclaration: ["id"], TSNonNullExpression: ["expression"], TSNeverKeyword: [], TSNullKeyword: [], TSNumberKeyword: [], TSObjectKeyword: [], + TSOptionalType: ["typeAnnotation"], TSParameterProperty: ["parameter"], + TSParenthesizedType: ["typeAnnotation"], TSPrivateKeyword: [], TSPropertySignature: ["typeAnnotation", "key", "initializer"], TSProtectedKeyword: [], @@ -70,13 +81,18 @@ module.exports = Evk.unionWith({ TSQualifiedName: ["left", "right"], TSQuestionToken: [], TSReadonlyKeyword: [], + TSRestType: ["typeAnnotation"], TSStaticKeyword: [], TSStringKeyword: [], TSSymbolKeyword: [], + TSThisType: [], + TSTupleType: ["elementTypes"], + TSTypeAliasDeclaration: ["id", "typeParameters", "typeAnnotation"], TSTypeAnnotation: ["typeAnnotation"], + TSTypeAssertion: ["typeAnnotation", "expression"], TSTypeLiteral: ["members"], TSTypeOperator: ["typeAnnotation"], - TSTypeParameter: ["constraint", "default"], + TSTypeParameter: ["name", "constraint", "default"], TSTypeParameterDeclaration: ["params"], TSTypeParameterInstantiation: ["params"], TSTypePredicate: ["typeAnnotation", "parameterName"], @@ -84,5 +100,6 @@ module.exports = Evk.unionWith({ TSTypeQuery: ["exprName"], TSUnionType: ["types"], TSUndefinedKeyword: [], + TSUnknownKeyword: [], TSVoidKeyword: [] });