diff --git a/packages/eslint-plugin/src/rules/no-unused-vars.ts b/packages/eslint-plugin/src/rules/no-unused-vars.ts index 2d63aa4564f8..544ba92938e8 100644 --- a/packages/eslint-plugin/src/rules/no-unused-vars.ts +++ b/packages/eslint-plugin/src/rules/no-unused-vars.ts @@ -24,22 +24,6 @@ export default util.createRule({ create(context) { const rules = baseRule.create(context); - /** - * Mark this function parameter as used - * @param node The node currently being traversed - */ - function markThisParameterAsUsed(node: TSESTree.Identifier): void { - if (node.name) { - const variable = context - .getScope() - .variables.find(scopeVar => scopeVar.name === node.name); - - if (variable) { - variable.eslintUsed = true; - } - } - } - /** * Mark heritage clause as used * @param node The node currently being traversed @@ -59,8 +43,6 @@ export default util.createRule({ } return Object.assign({}, rules, { - "FunctionDeclaration Identifier[name='this']": markThisParameterAsUsed, - "FunctionExpression Identifier[name='this']": markThisParameterAsUsed, 'TSTypeReference Identifier'(node: TSESTree.Identifier) { context.markVariableAsUsed(node.name); }, diff --git a/packages/eslint-plugin/tests/eslint-rules/no-shadow.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-shadow.test.ts index 78580e7296d9..847f20d1e3d9 100644 --- a/packages/eslint-plugin/tests/eslint-rules/no-shadow.test.ts +++ b/packages/eslint-plugin/tests/eslint-rules/no-shadow.test.ts @@ -21,6 +21,12 @@ function bar(foo: any) {} ` export abstract class Foo {} export class FooBar extends Foo {} + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/207 + ` +function test(this: Foo) { + function test2(this: Bar) {} +} ` ], invalid: [] diff --git a/packages/eslint-plugin/tests/eslint-rules/no-unused-vars.test.ts b/packages/eslint-plugin/tests/eslint-rules/no-unused-vars.test.ts deleted file mode 100644 index ffa062ddd4f4..000000000000 --- a/packages/eslint-plugin/tests/eslint-rules/no-unused-vars.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import rule from 'eslint/lib/rules/no-unused-vars'; -import { RuleTester } from '../RuleTester'; - -const ruleTester = new RuleTester({ - parserOptions: { - ecmaVersion: 6, - sourceType: 'module', - ecmaFeatures: {} - }, - parser: '@typescript-eslint/parser' -}); - -ruleTester.run('no-unused-vars', rule, { - valid: [ - // https://github.com/eslint/typescript-eslint-parser/issues/535 - ` -import { - observable, -} from 'mobx'; - -export default class ListModalStore { - @observable - orderList: IObservableArray = observable([]); -} - ` - ], - invalid: [] -}); diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts index 2e188c870a06..a9ca37ca4ea4 100644 --- a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts @@ -577,7 +577,36 @@ export function Foo() { ); } ` - } + }, + // https://github.com/eslint/typescript-eslint-parser/issues/535 + ` +import { observable } from 'mobx'; +export default class ListModalStore { + @observable + orderList: IObservableArray = observable([]); +} + `, + // https://github.com/typescript-eslint/typescript-eslint/issues/122#issuecomment-462008078 + ` +import { Dec, TypeA, Class } from 'test'; +export default class Foo { + constructor( + @Dec(Class) + private readonly prop: TypeA, + ) {} +} + `, + ` +import { Dec, TypeA, Class } from 'test'; +export default class Foo { + constructor( + @Dec(Class) + ...prop: TypeA, + ) { + prop() + } +} + ` ], invalid: [ diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index b6446af8de16..1aa26e9e5c4f 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -11,7 +11,7 @@ import { PatternVisitorCallback, PatternVisitorOptions } from 'eslint-scope/lib/options'; -import { TSESTree } from '@typescript-eslint/typescript-estree'; +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree'; /** * Define the override function of `Scope#__define` for global augmentation. @@ -90,6 +90,13 @@ class PatternVisitor extends OriginalPatternVisitor { this.rightHandNodes.push(node.typeAnnotation); } } + + TSParameterProperty(node: TSESTree.TSParameterProperty): void { + this.visit(node.parameter); + if (node.decorators) { + this.rightHandNodes.push(...node.decorators); + } + } } class Referencer extends OriginalReferencer { @@ -182,11 +189,16 @@ class Referencer extends OriginalReferencer { params[i], { processRightHandNodes: true }, (pattern, info) => { - innerScope.__define( - pattern, - new ParameterDefinition(pattern, node, i, info.rest) - ); - this.referencingDefaultValue(pattern, info.assignments, null, true); + if ( + pattern.type !== AST_NODE_TYPES.Identifier || + pattern.name !== 'this' + ) { + innerScope.__define( + pattern, + new ParameterDefinition(pattern, node, i, info.rest) + ); + this.referencingDefaultValue(pattern, info.assignments, null, true); + } } ); } diff --git a/packages/parser/src/visitor-keys.ts b/packages/parser/src/visitor-keys.ts index d3938529e820..eebaf2372174 100644 --- a/packages/parser/src/visitor-keys.ts +++ b/packages/parser/src/visitor-keys.ts @@ -4,7 +4,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({ // Additional estree nodes. Import: [], // Additional Properties. - ArrayPattern: ['elements', 'typeAnnotation'], + ArrayPattern: ['decorators', 'elements', 'typeAnnotation'], ArrowFunctionExpression: ['typeParameters', 'params', 'returnType', 'body'], ClassDeclaration: [ 'decorators', @@ -24,12 +24,13 @@ export const visitorKeys = eslintVisitorKeys.unionWith({ 'implements', 'body' ], + TaggedTemplateExpression: ['tag', 'typeParameters', 'quasi'], FunctionDeclaration: ['id', 'typeParameters', 'params', 'returnType', 'body'], FunctionExpression: ['id', 'typeParameters', 'params', 'returnType', 'body'], Identifier: ['decorators', 'typeAnnotation'], MethodDefinition: ['decorators', 'key', 'value'], - ObjectPattern: ['properties', 'typeAnnotation'], - RestElement: ['argument', 'typeAnnotation'], + ObjectPattern: ['decorators', 'properties', 'typeAnnotation'], + RestElement: ['decorators', 'argument', 'typeAnnotation'], NewExpression: ['callee', 'typeParameters', 'arguments'], CallExpression: ['callee', 'typeParameters', 'arguments'], // JSX @@ -56,7 +57,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({ TSConditionalType: ['checkType', 'extendsType', 'trueType', 'falseType'], TSConstructSignatureDeclaration: ['typeParameters', 'params', 'returnType'], TSConstructorType: ['typeParameters', 'params', 'returnType'], - TSDeclareFunction: ['id', 'typeParameters', 'params', 'returnType'], + TSDeclareFunction: ['id', 'typeParameters', 'params', 'returnType', 'body'], TSDeclareKeyword: [], TSEmptyBodyFunctionExpression: [ 'id', @@ -91,7 +92,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({ TSNumberKeyword: [], TSObjectKeyword: [], TSOptionalType: ['typeAnnotation'], - TSParameterProperty: ['parameter'], + TSParameterProperty: ['decorators', 'parameter'], TSParenthesizedType: ['typeAnnotation'], TSPrivateKeyword: [], TSPropertySignature: ['typeAnnotation', 'key', 'initializer'], diff --git a/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-array.ts b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-array.ts new file mode 100644 index 000000000000..568fbc0ad2e3 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-array.ts @@ -0,0 +1,3 @@ +export default class Foo { + constructor(@Dec []: string[]) {} +} diff --git a/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-identifier.ts b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-identifier.ts new file mode 100644 index 000000000000..f400e3d87e97 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-identifier.ts @@ -0,0 +1,3 @@ +export default class Foo { + constructor(@Dec test: string) {} +} diff --git a/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-object.ts b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-object.ts new file mode 100644 index 000000000000..fc9aa01431d8 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-object.ts @@ -0,0 +1,3 @@ +export default class Foo { + constructor(@Dec {}: any) {} +} diff --git a/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-parameter.ts b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-parameter.ts new file mode 100644 index 000000000000..e4a7c4907b51 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-parameter.ts @@ -0,0 +1,3 @@ +export default class Foo { + constructor(@Dec private readonly test: string) {} +} diff --git a/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-rest.ts b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-rest.ts new file mode 100644 index 000000000000..53a8ebc2b507 --- /dev/null +++ b/packages/parser/tests/fixtures/scope-analysis/decorator-parameter-property-rest.ts @@ -0,0 +1,3 @@ +export default class Foo { + constructor(@Dec ...test: string[]) {} +} diff --git a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap index 39fedcb8277b..e53ea5253c8c 100644 --- a/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/scope-analysis.ts.snap @@ -2473,51 +2473,115 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorators.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorator-parameter-property-array.ts 1`] = ` Object { - "$id": 19, + "$id": 7, "block": Object { "range": Array [ 0, - 198, + 65, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 18, + "$id": 6, "block": Object { "range": Array [ 0, - 198, + 65, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 6, + "$id": 5, "block": Object { "range": Array [ - 0, - 29, + 15, + 64, ], - "type": "FunctionDeclaration", + "type": "ClassDeclaration", }, - "childScopes": Array [], + "childScopes": Array [ + Object { + "$id": 4, + "block": Object { + "range": Array [ + 40, + 62, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 4, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 5, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], + }, + ], "functionExpressionScope": false, "isStrict": true, "references": Array [], - "throughReferences": Array [], - "type": "function", + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "class", "upperScope": Object { - "$ref": 18, + "$ref": 6, }, "variableMap": Object { - "arguments": Object { - "$ref": 4, - }, - "target": Object { - "$ref": 5, + "Foo": Object { + "$ref": 1, }, }, "variableScope": Object { @@ -2525,156 +2589,242 @@ Object { }, "variables": Array [ Object { - "$id": 4, - "defs": Array [], - "eslintUsed": undefined, - "identifiers": Array [], - "name": "arguments", - "references": Array [], - "scope": Object { - "$ref": 6, - }, - }, - Object { - "$id": 5, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "target", + "name": "Foo", "range": Array [ - 13, + 21, 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 29, + 15, + 64, ], - "type": "FunctionDeclaration", + "type": "ClassDeclaration", }, - "parent": null, - "type": "Parameter", + "parent": undefined, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "target", + "name": "Foo", "range": Array [ - 13, + 21, 24, ], "type": "Identifier", }, ], - "name": "target", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 6, + "$ref": 5, }, }, ], }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ Object { - "$id": 11, + "$ref": 3, + }, + ], + "type": "module", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 6, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 64, + ], + "type": "ClassDeclaration", + }, + "parent": null, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorator-parameter-property-identifier.ts 1`] = ` +Object { + "$id": 8, + "block": Object { + "range": Array [ + 0, + 65, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 7, + "block": Object { + "range": Array [ + 0, + 65, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 6, "block": Object { "range": Array [ - 30, - 100, + 15, + 64, ], - "type": "FunctionDeclaration", + "type": "ClassDeclaration", }, "childScopes": Array [ Object { - "$id": 10, + "$id": 5, "block": Object { "range": Array [ - 58, - 98, + 40, + 62, ], - "type": "ArrowFunctionExpression", + "type": "FunctionExpression", }, "childScopes": Array [], "functionExpressionScope": false, "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "function", - "upperScope": Object { - "$ref": 11, - }, - "variableMap": Object { - "propertyKey": Object { - "$ref": 9, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, }, - "target": Object { - "$ref": 8, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + "test": Object { + "$ref": 3, }, }, "variableScope": Object { - "$ref": 10, + "$ref": 5, }, "variables": Array [ Object { - "$id": 8, - "defs": Array [ - Object { - "name": Object { - "name": "target", - "range": Array [ - 59, - 70, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 58, - 98, - ], - "type": "ArrowFunctionExpression", - }, - "parent": null, - "type": "Parameter", - }, - ], + "$id": 2, + "defs": Array [], "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "target", - "range": Array [ - 59, - 70, - ], - "type": "Identifier", - }, - ], - "name": "target", + "identifiers": Array [], + "name": "arguments", "references": Array [], "scope": Object { - "$ref": 10, + "$ref": 5, }, }, Object { - "$id": 9, + "$id": 3, "defs": Array [ Object { "name": Object { - "name": "propertyKey", + "name": "test", "range": Array [ - 72, - 91, + 46, + 58, ], "type": "Identifier", }, "node": Object { "range": Array [ - 58, - 98, + 40, + 62, ], - "type": "ArrowFunctionExpression", + "type": "FunctionExpression", }, "parent": null, "type": "Parameter", @@ -2683,18 +2833,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "propertyKey", + "name": "test", "range": Array [ - 72, - 91, + 46, + 58, ], "type": "Identifier", }, ], - "name": "propertyKey", + "name": "test", "references": Array [], "scope": Object { - "$ref": 10, + "$ref": 5, }, }, ], @@ -2703,163 +2853,40 @@ Object { "functionExpressionScope": false, "isStrict": true, "references": Array [], - "throughReferences": Array [], - "type": "function", - "upperScope": Object { - "$ref": 18, - }, - "variableMap": Object { - "arguments": Object { - "$ref": 7, - }, - }, - "variableScope": Object { - "$ref": 11, - }, - "variables": Array [ - Object { - "$id": 7, - "defs": Array [], - "eslintUsed": undefined, - "identifiers": Array [], - "name": "arguments", - "references": Array [], - "scope": Object { - "$ref": 11, - }, - }, - ], - }, - Object { - "$id": 17, - "block": Object { - "range": Array [ - 102, - 197, - ], - "type": "ClassDeclaration", - }, - "childScopes": Array [ - Object { - "$id": 16, - "block": Object { - "range": Array [ - 159, - 195, - ], - "type": "FunctionExpression", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "function", - "upperScope": Object { - "$ref": 17, - }, - "variableMap": Object { - "arguments": Object { - "$ref": 15, - }, - }, - "variableScope": Object { - "$ref": 16, - }, - "variables": Array [ - Object { - "$id": 15, - "defs": Array [], - "eslintUsed": undefined, - "identifiers": Array [], - "name": "arguments", - "references": Array [], - "scope": Object { - "$ref": 16, - }, - }, - ], - }, - ], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ - Object { - "$id": 13, - "from": Object { - "$ref": 17, - }, - "identifier": Object { - "name": "gec", - "range": Array [ - 122, - 125, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 1, - }, - "writeExpr": undefined, - }, - Object { - "$id": 14, - "from": Object { - "$ref": 17, - }, - "identifier": Object { - "name": "gec", - "range": Array [ - 147, - 150, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 1, - }, - "writeExpr": undefined, - }, - ], "throughReferences": Array [ Object { - "$ref": 13, - }, - Object { - "$ref": 14, + "$ref": 4, }, ], "type": "class", "upperScope": Object { - "$ref": 18, + "$ref": 7, }, "variableMap": Object { - "C": Object { - "$ref": 12, + "Foo": Object { + "$ref": 1, }, }, "variableScope": Object { - "$ref": 18, + "$ref": 7, }, "variables": Array [ Object { - "$id": 12, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "C", + "name": "Foo", "range": Array [ - 113, - 114, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 102, - 197, + 15, + 64, ], "type": "ClassDeclaration", }, @@ -2870,18 +2897,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "C", + "name": "Foo", "range": Array [ - 113, - 114, + 21, + 24, ], "type": "Identifier", }, ], - "name": "C", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 17, + "$ref": 6, }, }, ], @@ -2889,45 +2916,23 @@ Object { ], "functionExpressionScope": false, "isStrict": true, - "references": Array [ + "references": Array [], + "throughReferences": Array [ Object { - "$id": 3, - "from": Object { - "$ref": 18, - }, - "identifier": Object { - "name": "dec", - "range": Array [ - 103, - 106, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": undefined, + "$ref": 4, }, ], - "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 19, + "$ref": 8, }, "variableMap": Object { - "C": Object { - "$ref": 2, - }, - "dec": Object { + "Foo": Object { "$ref": 0, }, - "gec": Object { - "$ref": 1, - }, }, "variableScope": Object { - "$ref": 18, + "$ref": 7, }, "variables": Array [ Object { @@ -2935,108 +2940,17 @@ Object { "defs": Array [ Object { "name": Object { - "name": "dec", - "range": Array [ - 9, - 12, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 0, - 29, - ], - "type": "FunctionDeclaration", - }, - "parent": null, - "type": "FunctionName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "dec", - "range": Array [ - 9, - 12, - ], - "type": "Identifier", - }, - ], - "name": "dec", - "references": Array [ - Object { - "$ref": 3, - }, - ], - "scope": Object { - "$ref": 18, - }, - }, - Object { - "$id": 1, - "defs": Array [ - Object { - "name": Object { - "name": "gec", - "range": Array [ - 39, - 42, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 30, - 100, - ], - "type": "FunctionDeclaration", - }, - "parent": null, - "type": "FunctionName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "gec", - "range": Array [ - 39, - 42, - ], - "type": "Identifier", - }, - ], - "name": "gec", - "references": Array [ - Object { - "$ref": 13, - }, - Object { - "$ref": 14, - }, - ], - "scope": Object { - "$ref": 18, - }, - }, - Object { - "$id": 2, - "defs": Array [ - Object { - "name": Object { - "name": "C", + "name": "Foo", "range": Array [ - 113, - 114, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 102, - 197, + 15, + 64, ], "type": "ClassDeclaration", }, @@ -3047,18 +2961,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "C", + "name": "Foo", "range": Array [ - 113, - 114, + 21, + 24, ], "type": "Identifier", }, ], - "name": "C", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 18, + "$ref": 7, }, }, ], @@ -3067,367 +2981,174 @@ Object { "functionExpressionScope": false, "isStrict": false, "references": Array [], - "throughReferences": Array [], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], "type": "global", "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 19, + "$ref": 8, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/enum.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorator-parameter-property-object.ts 1`] = ` Object { - "$id": 15, + "$id": 7, "block": Object { "range": Array [ 0, - 71, + 60, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 14, + "$id": 6, "block": Object { "range": Array [ 0, - 71, + 60, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 13, + "$id": 5, "block": Object { "range": Array [ - 20, - 70, + 15, + 59, ], - "type": "TSEnumDeclaration", + "type": "ClassDeclaration", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ + "childScopes": Array [ Object { - "$id": 6, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "A", - "range": Array [ - 33, - 34, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 3, - }, - "writeExpr": Object { - "name": "a", + "$id": 4, + "block": Object { "range": Array [ - 37, - 38, + 40, + 57, ], - "type": "Identifier", + "type": "FunctionExpression", }, - }, - Object { - "$id": 7, - "from": Object { - "$ref": 13, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 4, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 5, }, - "identifier": Object { - "name": "a", - "range": Array [ - 37, - 38, - ], - "type": "Identifier", + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, }, - "kind": "r", - "resolved": Object { - "$ref": 0, + "variableScope": Object { + "$ref": 4, }, - "writeExpr": undefined, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ Object { - "$id": 8, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "B", - "range": Array [ - 44, - 45, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 4, - }, - "writeExpr": Object { - "range": Array [ - 48, - 53, - ], - "type": "BinaryExpression", - }, - }, - Object { - "$id": 9, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 48, - 49, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": undefined, - }, - Object { - "$id": 10, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "C", - "range": Array [ - 59, - 60, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 5, - }, - "writeExpr": Object { - "range": Array [ - 63, - 68, - ], - "type": "BinaryExpression", - }, - }, - Object { - "$id": 11, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "A", - "range": Array [ - 63, - 64, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 3, - }, - "writeExpr": undefined, - }, - Object { - "$id": 12, - "from": Object { - "$ref": 13, - }, - "identifier": Object { - "name": "B", - "range": Array [ - 67, - 68, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 4, - }, - "writeExpr": undefined, - }, - ], - "throughReferences": Array [ - Object { - "$ref": 7, - }, - Object { - "$ref": 9, + "$ref": 3, }, ], - "type": "enum", + "type": "class", "upperScope": Object { - "$ref": 14, + "$ref": 6, }, "variableMap": Object { - "A": Object { - "$ref": 3, - }, - "B": Object { - "$ref": 4, - }, - "C": Object { - "$ref": 5, + "Foo": Object { + "$ref": 1, }, }, "variableScope": Object { - "$ref": 14, + "$ref": 6, }, "variables": Array [ Object { - "$id": 3, - "defs": Array [ - Object { - "name": Object { - "name": "A", - "range": Array [ - 33, - 34, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 33, - 38, - ], - "type": "TSEnumMember", - }, - "parent": undefined, - "type": "EnumMemberName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "A", - "range": Array [ - 33, - 34, - ], - "type": "Identifier", - }, - ], - "name": "A", - "references": Array [ - Object { - "$ref": 6, - }, - Object { - "$ref": 11, - }, - ], - "scope": Object { - "$ref": 13, - }, - }, - Object { - "$id": 4, - "defs": Array [ - Object { - "name": Object { - "name": "B", - "range": Array [ - 44, - 45, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 44, - 53, - ], - "type": "TSEnumMember", - }, - "parent": undefined, - "type": "EnumMemberName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "B", - "range": Array [ - 44, - 45, - ], - "type": "Identifier", - }, - ], - "name": "B", - "references": Array [ - Object { - "$ref": 8, - }, - Object { - "$ref": 12, - }, - ], - "scope": Object { - "$ref": 13, - }, - }, - Object { - "$id": 5, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "C", + "name": "Foo", "range": Array [ - 59, - 60, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ + 15, 59, - 68, ], - "type": "TSEnumMember", + "type": "ClassDeclaration", }, "parent": undefined, - "type": "EnumMemberName", + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "C", + "name": "Foo", "range": Array [ - 59, - 60, + 21, + 24, ], "type": "Identifier", }, ], - "name": "C", - "references": Array [ - Object { - "$ref": 10, - }, - ], + "name": "Foo", + "references": Array [], "scope": Object { - "$ref": 13, + "$ref": 5, }, }, ], @@ -3435,48 +3156,23 @@ Object { ], "functionExpressionScope": false, "isStrict": true, - "references": Array [ + "references": Array [], + "throughReferences": Array [ Object { - "$id": 2, - "from": Object { - "$ref": 14, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 6, - 15, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": Object { - "range": Array [ - 18, - 19, - ], - "type": "Literal", - }, + "$ref": 3, }, ], - "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 15, + "$ref": 7, }, "variableMap": Object { - "E": Object { - "$ref": 1, - }, - "a": Object { + "Foo": Object { "$ref": 0, }, }, "variableScope": Object { - "$ref": 14, + "$ref": 6, }, "variables": Array [ Object { @@ -3484,95 +3180,39 @@ Object { "defs": Array [ Object { "name": Object { - "name": "a", - "range": Array [ - 6, - 15, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 6, - 19, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 0, - 19, - ], - "type": "VariableDeclaration", - }, - "type": "Variable", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "a", - "range": Array [ - 6, - 15, - ], - "type": "Identifier", - }, - ], - "name": "a", - "references": Array [ - Object { - "$ref": 2, - }, - Object { - "$ref": 7, - }, - Object { - "$ref": 9, - }, - ], - "scope": Object { - "$ref": 14, - }, - }, - Object { - "$id": 1, - "defs": Array [ - Object { - "name": Object { - "name": "E", + "name": "Foo", "range": Array [ - 25, - 26, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 20, - 70, + 15, + 59, ], - "type": "TSEnumDeclaration", + "type": "ClassDeclaration", }, - "parent": undefined, - "type": "EnumName", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "E", + "name": "Foo", "range": Array [ - 25, - 26, + 21, + 24, ], "type": "Identifier", }, ], - "name": "E", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 14, + "$ref": 6, }, }, ], @@ -3581,153 +3221,241 @@ Object { "functionExpressionScope": false, "isStrict": false, "references": Array [], - "throughReferences": Array [], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], "type": "global", "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 15, + "$ref": 7, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/enum-string.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorator-parameter-property-parameter.ts 1`] = ` Object { - "$id": 5, + "$id": 8, "block": Object { "range": Array [ 0, - 29, + 82, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 4, + "$id": 7, "block": Object { "range": Array [ 0, - 29, + 82, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 3, + "$id": 6, "block": Object { "range": Array [ - 0, - 28, + 15, + 81, ], - "type": "TSEnumDeclaration", + "type": "ClassDeclaration", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ + "childScopes": Array [ Object { - "$id": 2, - "from": Object { - "$ref": 3, - }, - "identifier": Object { - "name": "BAR", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 1, - }, - "writeExpr": Object { + "$id": 5, + "block": Object { "range": Array [ - 21, - 26, + 40, + 79, ], - "type": "Literal", + "type": "FunctionExpression", }, - }, - ], - "throughReferences": Array [], - "type": "enum", - "upperScope": Object { - "$ref": 4, - }, - "variableMap": Object { - "BAR": Object { - "$ref": 1, - }, - }, - "variableScope": Object { - "$ref": 4, - }, - "variables": Array [ - Object { - "$id": 1, - "defs": Array [ + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ Object { - "name": Object { - "name": "BAR", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", + "$id": 4, + "from": Object { + "$ref": 5, }, - "node": Object { + "identifier": Object { + "name": "Dec", "range": Array [ - 15, - 26, + 42, + 45, ], - "type": "TSEnumMember", + "type": "Identifier", }, - "parent": undefined, - "type": "EnumMemberName", + "kind": "r", + "resolved": null, + "writeExpr": undefined, }, ], - "eslintUsed": undefined, - "identifiers": Array [ + "throughReferences": Array [ Object { - "name": "BAR", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", + "$ref": 4, }, ], - "name": "BAR", - "references": Array [ - Object { + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { "$ref": 2, }, - ], - "scope": Object { - "$ref": 3, + "test": Object { + "$ref": 3, + }, }, - }, - ], - }, - ], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "module", - "upperScope": Object { - "$ref": 5, - }, - "variableMap": Object { - "Foo": Object { - "$ref": 0, - }, - }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "test", + "range": Array [ + 63, + 75, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 40, + 79, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "test", + "range": Array [ + 63, + 75, + ], + "type": "Identifier", + }, + ], + "name": "test", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 81, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "module", + "upperScope": Object { + "$ref": 8, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, "variableScope": Object { - "$ref": 4, + "$ref": 7, }, "variables": Array [ Object { @@ -3737,20 +3465,20 @@ Object { "name": Object { "name": "Foo", "range": Array [ - 5, - 8, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 28, + 15, + 81, ], - "type": "TSEnumDeclaration", + "type": "ClassDeclaration", }, - "parent": undefined, - "type": "EnumName", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, @@ -3758,8 +3486,8 @@ Object { Object { "name": "Foo", "range": Array [ - 5, - 8, + 21, + 24, ], "type": "Identifier", }, @@ -3767,82 +3495,10 @@ Object { "name": "Foo", "references": Array [], "scope": Object { - "$ref": 4, - }, - }, - ], - }, - ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 5, - }, - "variables": Array [], -} -`; - -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/export-as-namespace.ts 1`] = ` -Object { - "$id": 2, - "block": Object { - "range": Array [ - 0, - 23, - ], - "type": "Program", - }, - "childScopes": Array [ - Object { - "$id": 1, - "block": Object { - "range": Array [ - 0, - 23, - ], - "type": "Program", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ - Object { - "$id": 0, - "from": Object { - "$ref": 1, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 20, - 21, - ], - "type": "Identifier", + "$ref": 7, }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, - }, - ], - "throughReferences": Array [ - Object { - "$ref": 0, }, ], - "type": "module", - "upperScope": Object { - "$ref": 2, - }, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 1, - }, - "variables": Array [], }, ], "functionExpressionScope": false, @@ -3850,75 +3506,282 @@ Object { "references": Array [], "throughReferences": Array [ Object { - "$ref": 0, + "$ref": 4, }, ], "type": "global", "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 2, + "$ref": 8, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/expression-as.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorator-parameter-property-rest.ts 1`] = ` Object { - "$id": 2, + "$id": 8, "block": Object { "range": Array [ 0, - 27, + 70, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 1, + "$id": 7, "block": Object { "range": Array [ 0, - 27, + 70, ], "type": "Program", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ + "childScopes": Array [ Object { - "$id": 0, - "from": Object { - "$ref": 1, - }, - "identifier": Object { - "name": "a", + "$id": 6, + "block": Object { "range": Array [ - 1, - 2, + 15, + 69, ], - "type": "Identifier", + "type": "ClassDeclaration", }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, - }, + "childScopes": Array [ + Object { + "$id": 5, + "block": Object { + "range": Array [ + 40, + 67, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + "test": Object { + "$ref": 3, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "test", + "range": Array [ + 49, + 53, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 40, + 67, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "test", + "range": Array [ + 49, + 53, + ], + "type": "Identifier", + }, + ], + "name": "test", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 69, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], "throughReferences": Array [ Object { - "$ref": 0, + "$ref": 4, }, ], "type": "module", "upperScope": Object { - "$ref": 2, + "$ref": 8, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, }, - "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 7, }, - "variables": Array [], + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 69, + ], + "type": "ClassDeclaration", + }, + "parent": null, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 7, + }, + }, + ], }, ], "functionExpressionScope": false, @@ -3926,66 +3789,1532 @@ Object { "references": Array [], "throughReferences": Array [ Object { - "$ref": 0, + "$ref": 4, }, ], "type": "global", "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 2, + "$ref": 8, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/expression-type-parameters.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/decorators.ts 1`] = ` Object { - "$id": 15, + "$id": 19, "block": Object { "range": Array [ 0, - 67, + 198, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 14, + "$id": 18, "block": Object { "range": Array [ 0, - 67, + 198, ], "type": "Program", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ + "childScopes": Array [ Object { "$id": 6, - "from": Object { - "$ref": 14, - }, - "identifier": Object { - "name": "foo", + "block": Object { "range": Array [ - 28, - 31, + 0, + 29, ], - "type": "Identifier", - }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, - }, - Object { - "$id": 7, - "from": Object { - "$ref": 14, + "type": "FunctionDeclaration", }, - "identifier": Object { + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 18, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 4, + }, + "target": Object { + "$ref": 5, + }, + }, + "variableScope": Object { + "$ref": 6, + }, + "variables": Array [ + Object { + "$id": 4, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + Object { + "$id": 5, + "defs": Array [ + Object { + "name": Object { + "name": "target", + "range": Array [ + 13, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 29, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "target", + "range": Array [ + 13, + 24, + ], + "type": "Identifier", + }, + ], + "name": "target", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], + }, + Object { + "$id": 11, + "block": Object { + "range": Array [ + 30, + 100, + ], + "type": "FunctionDeclaration", + }, + "childScopes": Array [ + Object { + "$id": 10, + "block": Object { + "range": Array [ + 58, + 98, + ], + "type": "ArrowFunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 11, + }, + "variableMap": Object { + "propertyKey": Object { + "$ref": 9, + }, + "target": Object { + "$ref": 8, + }, + }, + "variableScope": Object { + "$ref": 10, + }, + "variables": Array [ + Object { + "$id": 8, + "defs": Array [ + Object { + "name": Object { + "name": "target", + "range": Array [ + 59, + 70, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 58, + 98, + ], + "type": "ArrowFunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "target", + "range": Array [ + 59, + 70, + ], + "type": "Identifier", + }, + ], + "name": "target", + "references": Array [], + "scope": Object { + "$ref": 10, + }, + }, + Object { + "$id": 9, + "defs": Array [ + Object { + "name": Object { + "name": "propertyKey", + "range": Array [ + 72, + 91, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 58, + 98, + ], + "type": "ArrowFunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "propertyKey", + "range": Array [ + 72, + 91, + ], + "type": "Identifier", + }, + ], + "name": "propertyKey", + "references": Array [], + "scope": Object { + "$ref": 10, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 18, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 7, + }, + }, + "variableScope": Object { + "$ref": 11, + }, + "variables": Array [ + Object { + "$id": 7, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 11, + }, + }, + ], + }, + Object { + "$id": 17, + "block": Object { + "range": Array [ + 102, + 197, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [ + Object { + "$id": 16, + "block": Object { + "range": Array [ + 159, + 195, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "function", + "upperScope": Object { + "$ref": 17, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 15, + }, + }, + "variableScope": Object { + "$ref": 16, + }, + "variables": Array [ + Object { + "$id": 15, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 16, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 13, + "from": Object { + "$ref": 17, + }, + "identifier": Object { + "name": "gec", + "range": Array [ + 122, + 125, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": undefined, + }, + Object { + "$id": 14, + "from": Object { + "$ref": 17, + }, + "identifier": Object { + "name": "gec", + "range": Array [ + 147, + 150, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 13, + }, + Object { + "$ref": 14, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 18, + }, + "variableMap": Object { + "C": Object { + "$ref": 12, + }, + }, + "variableScope": Object { + "$ref": 18, + }, + "variables": Array [ + Object { + "$id": 12, + "defs": Array [ + Object { + "name": Object { + "name": "C", + "range": Array [ + 113, + 114, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 102, + 197, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "C", + "range": Array [ + 113, + 114, + ], + "type": "Identifier", + }, + ], + "name": "C", + "references": Array [], + "scope": Object { + "$ref": 17, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 18, + }, + "identifier": Object { + "name": "dec", + "range": Array [ + 103, + 106, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 19, + }, + "variableMap": Object { + "C": Object { + "$ref": 2, + }, + "dec": Object { + "$ref": 0, + }, + "gec": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 18, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "dec", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 29, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "dec", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + ], + "name": "dec", + "references": Array [ + Object { + "$ref": 3, + }, + ], + "scope": Object { + "$ref": 18, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "gec", + "range": Array [ + 39, + 42, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 30, + 100, + ], + "type": "FunctionDeclaration", + }, + "parent": null, + "type": "FunctionName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "gec", + "range": Array [ + 39, + 42, + ], + "type": "Identifier", + }, + ], + "name": "gec", + "references": Array [ + Object { + "$ref": 13, + }, + Object { + "$ref": 14, + }, + ], + "scope": Object { + "$ref": 18, + }, + }, + Object { + "$id": 2, + "defs": Array [ + Object { + "name": Object { + "name": "C", + "range": Array [ + 113, + 114, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 102, + 197, + ], + "type": "ClassDeclaration", + }, + "parent": null, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "C", + "range": Array [ + 113, + 114, + ], + "type": "Identifier", + }, + ], + "name": "C", + "references": Array [], + "scope": Object { + "$ref": 18, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 19, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/enum.ts 1`] = ` +Object { + "$id": 15, + "block": Object { + "range": Array [ + 0, + 71, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 14, + "block": Object { + "range": Array [ + 0, + 71, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 13, + "block": Object { + "range": Array [ + 20, + 70, + ], + "type": "TSEnumDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 6, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "A", + "range": Array [ + 33, + 34, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 3, + }, + "writeExpr": Object { + "name": "a", + "range": Array [ + 37, + 38, + ], + "type": "Identifier", + }, + }, + Object { + "$id": 7, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 37, + 38, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + Object { + "$id": 8, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "B", + "range": Array [ + 44, + 45, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 4, + }, + "writeExpr": Object { + "range": Array [ + 48, + 53, + ], + "type": "BinaryExpression", + }, + }, + Object { + "$id": 9, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 48, + 49, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + Object { + "$id": 10, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "C", + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 5, + }, + "writeExpr": Object { + "range": Array [ + 63, + 68, + ], + "type": "BinaryExpression", + }, + }, + Object { + "$id": 11, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "A", + "range": Array [ + 63, + 64, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 3, + }, + "writeExpr": undefined, + }, + Object { + "$id": 12, + "from": Object { + "$ref": 13, + }, + "identifier": Object { + "name": "B", + "range": Array [ + 67, + 68, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 4, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 7, + }, + Object { + "$ref": 9, + }, + ], + "type": "enum", + "upperScope": Object { + "$ref": 14, + }, + "variableMap": Object { + "A": Object { + "$ref": 3, + }, + "B": Object { + "$ref": 4, + }, + "C": Object { + "$ref": 5, + }, + }, + "variableScope": Object { + "$ref": 14, + }, + "variables": Array [ + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "A", + "range": Array [ + 33, + 34, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 33, + 38, + ], + "type": "TSEnumMember", + }, + "parent": undefined, + "type": "EnumMemberName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "A", + "range": Array [ + 33, + 34, + ], + "type": "Identifier", + }, + ], + "name": "A", + "references": Array [ + Object { + "$ref": 6, + }, + Object { + "$ref": 11, + }, + ], + "scope": Object { + "$ref": 13, + }, + }, + Object { + "$id": 4, + "defs": Array [ + Object { + "name": Object { + "name": "B", + "range": Array [ + 44, + 45, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 44, + 53, + ], + "type": "TSEnumMember", + }, + "parent": undefined, + "type": "EnumMemberName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "B", + "range": Array [ + 44, + 45, + ], + "type": "Identifier", + }, + ], + "name": "B", + "references": Array [ + Object { + "$ref": 8, + }, + Object { + "$ref": 12, + }, + ], + "scope": Object { + "$ref": 13, + }, + }, + Object { + "$id": 5, + "defs": Array [ + Object { + "name": Object { + "name": "C", + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 59, + 68, + ], + "type": "TSEnumMember", + }, + "parent": undefined, + "type": "EnumMemberName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "C", + "range": Array [ + 59, + 60, + ], + "type": "Identifier", + }, + ], + "name": "C", + "references": Array [ + Object { + "$ref": 10, + }, + ], + "scope": Object { + "$ref": 13, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 2, + "from": Object { + "$ref": 14, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 18, + 19, + ], + "type": "Literal", + }, + }, + ], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 15, + }, + "variableMap": Object { + "E": Object { + "$ref": 1, + }, + "a": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 14, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 19, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 19, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [ + Object { + "$ref": 2, + }, + Object { + "$ref": 7, + }, + Object { + "$ref": 9, + }, + ], + "scope": Object { + "$ref": 14, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "E", + "range": Array [ + 25, + 26, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 20, + 70, + ], + "type": "TSEnumDeclaration", + }, + "parent": undefined, + "type": "EnumName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "E", + "range": Array [ + 25, + 26, + ], + "type": "Identifier", + }, + ], + "name": "E", + "references": Array [], + "scope": Object { + "$ref": 14, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 15, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/enum-string.ts 1`] = ` +Object { + "$id": 5, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 4, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 28, + ], + "type": "TSEnumDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 2, + "from": Object { + "$ref": 3, + }, + "identifier": Object { + "name": "BAR", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": Object { + "range": Array [ + 21, + 26, + ], + "type": "Literal", + }, + }, + ], + "throughReferences": Array [], + "type": "enum", + "upperScope": Object { + "$ref": 4, + }, + "variableMap": Object { + "BAR": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "BAR", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 26, + ], + "type": "TSEnumMember", + }, + "parent": undefined, + "type": "EnumMemberName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "BAR", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + ], + "name": "BAR", + "references": Array [ + Object { + "$ref": 2, + }, + ], + "scope": Object { + "$ref": 3, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 5, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 28, + ], + "type": "TSEnumDeclaration", + }, + "parent": undefined, + "type": "EnumName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/export-as-namespace.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 23, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 23, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "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": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/expression-as.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 27, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 27, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "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": "module", + "upperScope": Object { + "$ref": 2, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 0, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/expression-type-parameters.ts 1`] = ` +Object { + "$id": 15, + "block": Object { + "range": Array [ + 0, + 67, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 14, + "block": Object { + "range": Array [ + 0, + 67, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 6, + "from": Object { + "$ref": 14, + }, + "identifier": Object { + "name": "foo", + "range": Array [ + 28, + 31, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + Object { + "$id": 7, + "from": Object { + "$ref": 14, + }, + "identifier": Object { "name": "a", "range": Array [ 37, @@ -9680,15 +11009,267 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-parenthesized-type.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference.src.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 10, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 10, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "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, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference-generic.src.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 22, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 22, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 2, + }, + "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, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 2, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-parenthesized-type.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts 1`] = ` Object { - "$id": 1, + "$id": 2, "block": Object { "range": Array [ 0, @@ -9698,7 +11279,7 @@ Object { }, "childScopes": Array [ Object { - "$id": 0, + "$id": 1, "block": Object { "range": Array [ 0, @@ -9713,13 +11294,64 @@ Object { "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 1, + "$ref": 2, + }, + "variableMap": Object { + "x": Object { + "$ref": 0, + }, }, - "variableMap": Object {}, "variableScope": Object { - "$ref": 0, + "$ref": 1, }, - "variables": Array [], + "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, + }, + }, + ], }, ], "functionExpressionScope": false, @@ -9730,19 +11362,19 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 2, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple.src.ts 1`] = ` Object { "$id": 2, "block": Object { "range": Array [ 0, - 10, + 33, ], "type": "Program", }, @@ -9752,7 +11384,7 @@ Object { "block": Object { "range": Array [ 0, - 10, + 33, ], "type": "Program", }, @@ -9782,21 +11414,21 @@ Object { "name": "x", "range": Array [ 4, - 8, + 31, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 8, + 31, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 9, + 32, ], "type": "VariableDeclaration", }, @@ -9809,7 +11441,7 @@ Object { "name": "x", "range": Array [ 4, - 8, + 31, ], "type": "Identifier", }, @@ -9837,13 +11469,13 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference-generic.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-empty.src.ts 1`] = ` Object { "$id": 2, "block": Object { "range": Array [ 0, - 22, + 11, ], "type": "Program", }, @@ -9853,7 +11485,7 @@ Object { "block": Object { "range": Array [ 0, - 22, + 11, ], "type": "Program", }, @@ -9883,21 +11515,21 @@ Object { "name": "x", "range": Array [ 4, - 20, + 9, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 20, + 9, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 21, + 10, ], "type": "VariableDeclaration", }, @@ -9910,7 +11542,7 @@ Object { "name": "x", "range": Array [ 4, - 20, + 9, ], "type": "Identifier", }, @@ -9938,13 +11570,13 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-reference-generic-nested.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-optional.src.ts 1`] = ` Object { "$id": 2, "block": Object { "range": Array [ 0, - 29, + 45, ], "type": "Program", }, @@ -9954,7 +11586,7 @@ Object { "block": Object { "range": Array [ 0, - 29, + 45, ], "type": "Program", }, @@ -9984,21 +11616,21 @@ Object { "name": "x", "range": Array [ 4, - 27, + 44, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 27, + 44, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 28, + 44, ], "type": "VariableDeclaration", }, @@ -10011,7 +11643,7 @@ Object { "name": "x", "range": Array [ 4, - 27, + 44, ], "type": "Identifier", }, @@ -10039,13 +11671,13 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-rest.src.ts 1`] = ` Object { "$id": 2, "block": Object { "range": Array [ 0, - 33, + 29, ], "type": "Program", }, @@ -10055,7 +11687,7 @@ Object { "block": Object { "range": Array [ 0, - 33, + 29, ], "type": "Program", }, @@ -10085,21 +11717,21 @@ Object { "name": "x", "range": Array [ 4, - 31, + 28, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 31, + 28, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 32, + 28, ], "type": "VariableDeclaration", }, @@ -10112,7 +11744,7 @@ Object { "name": "x", "range": Array [ 4, - 31, + 28, ], "type": "Identifier", }, @@ -10140,13 +11772,63 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-empty.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-type.src.ts 1`] = ` +Object { + "$id": 1, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 29, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-type-literal.src.ts 1`] = ` Object { "$id": 2, "block": Object { "range": Array [ 0, - 11, + 24, ], "type": "Program", }, @@ -10156,7 +11838,7 @@ Object { "block": Object { "range": Array [ 0, - 11, + 24, ], "type": "Program", }, @@ -10170,7 +11852,7 @@ Object { "$ref": 2, }, "variableMap": Object { - "x": Object { + "obj": Object { "$ref": 0, }, }, @@ -10183,24 +11865,24 @@ Object { "defs": Array [ Object { "name": Object { - "name": "x", + "name": "obj", "range": Array [ 4, - 9, + 22, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 9, + 22, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 10, + 23, ], "type": "VariableDeclaration", }, @@ -10210,15 +11892,15 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "x", + "name": "obj", "range": Array [ 4, - 9, + 22, ], "type": "Identifier", }, ], - "name": "x", + "name": "obj", "references": Array [], "scope": Object { "$ref": 1, @@ -10241,23 +11923,23 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-optional.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-type-operator.src.ts 1`] = ` Object { - "$id": 2, + "$id": 3, "block": Object { "range": Array [ 0, - 45, + 38, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 1, + "$id": 2, "block": Object { "range": Array [ 0, - 45, + 38, ], "type": "Program", }, @@ -10268,40 +11950,89 @@ Object { "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 2, + "$ref": 3, }, "variableMap": Object { "x": Object { "$ref": 0, }, - }, - "variableScope": Object { - "$ref": 1, - }, - "variables": Array [ + "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": 0, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "x", + "name": "y", "range": Array [ - 4, - 44, + 20, + 36, ], "type": "Identifier", }, "node": Object { "range": Array [ - 4, - 44, + 20, + 36, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ - 0, - 44, + 16, + 37, ], "type": "VariableDeclaration", }, @@ -10311,18 +12042,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "x", + "name": "y", "range": Array [ - 4, - 44, + 20, + 36, ], "type": "Identifier", }, ], - "name": "x", + "name": "y", "references": Array [], "scope": Object { - "$ref": 1, + "$ref": 2, }, }, ], @@ -10336,40 +12067,62 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 2, + "$ref": 3, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-rest.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-typeof.src.ts 1`] = ` Object { - "$id": 2, + "$id": 3, "block": Object { "range": Array [ 0, - 29, + 19, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 1, + "$id": 2, "block": Object { "range": Array [ 0, - 29, + 19, ], "type": "Program", }, "childScopes": Array [], "functionExpressionScope": false, "isStrict": true, - "references": Array [], - "throughReferences": Array [], + "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": "module", "upperScope": Object { - "$ref": 2, + "$ref": 3, }, "variableMap": Object { "x": Object { @@ -10377,7 +12130,7 @@ Object { }, }, "variableScope": Object { - "$ref": 1, + "$ref": 2, }, "variables": Array [ Object { @@ -10388,21 +12141,21 @@ Object { "name": "x", "range": Array [ 4, - 28, + 17, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 28, + 17, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 28, + 18, ], "type": "VariableDeclaration", }, @@ -10415,7 +12168,7 @@ Object { "name": "x", "range": Array [ 4, - 28, + 17, ], "type": "Identifier", }, @@ -10423,7 +12176,7 @@ Object { "name": "x", "references": Array [], "scope": Object { - "$ref": 1, + "$ref": 2, }, }, ], @@ -10432,84 +12185,38 @@ Object { "functionExpressionScope": false, "isStrict": false, "references": Array [], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 2, - }, - "variables": Array [], -} -`; - -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-tuple-type.src.ts 1`] = ` -Object { - "$id": 1, - "block": Object { - "range": Array [ - 0, - 29, - ], - "type": "Program", - }, - "childScopes": Array [ + "throughReferences": Array [ Object { - "$id": 0, - "block": Object { - "range": Array [ - 0, - 29, - ], - "type": "Program", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "module", - "upperScope": Object { - "$ref": 1, - }, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 0, - }, - "variables": Array [], + "$ref": 1, }, ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [], "type": "global", "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 1, + "$ref": 3, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-type-literal.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-union-intersection.src.ts 1`] = ` Object { - "$id": 2, + "$id": 5, "block": Object { "range": Array [ 0, - 24, + 161, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 1, + "$id": 4, "block": Object { "range": Array [ 0, - 24, + 161, ], "type": "Program", }, @@ -10520,15 +12227,24 @@ Object { "throughReferences": Array [], "type": "module", "upperScope": Object { - "$ref": 2, + "$ref": 5, }, "variableMap": Object { - "obj": Object { + "intersection": Object { + "$ref": 1, + }, + "precedence1": Object { + "$ref": 2, + }, + "precedence2": Object { + "$ref": 3, + }, + "union": Object { "$ref": 0, }, }, "variableScope": Object { - "$ref": 1, + "$ref": 4, }, "variables": Array [ Object { @@ -10536,24 +12252,24 @@ Object { "defs": Array [ Object { "name": Object { - "name": "obj", + "name": "union", "range": Array [ 4, - 22, + 36, ], "type": "Identifier", }, "node": Object { "range": Array [ 4, - 22, + 36, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 23, + 37, ], "type": "VariableDeclaration", }, @@ -10563,101 +12279,89 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "obj", + "name": "union", "range": Array [ 4, - 22, + 36, ], "type": "Identifier", }, ], - "name": "obj", + "name": "union", "references": Array [], "scope": Object { - "$ref": 1, + "$ref": 4, }, }, - ], - }, - ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 2, - }, - "variables": Array [], -} -`; - -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-type-operator.src.ts 1`] = ` -Object { - "$id": 3, - "block": Object { - "range": Array [ - 0, - 38, - ], - "type": "Program", - }, - "childScopes": Array [ - Object { - "$id": 2, - "block": Object { - "range": Array [ - 0, - 38, - ], - "type": "Program", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "module", - "upperScope": Object { - "$ref": 3, - }, - "variableMap": Object { - "x": Object { - "$ref": 0, - }, - "y": Object { - "$ref": 1, + 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, + }, }, - }, - "variableScope": Object { - "$ref": 2, - }, - "variables": Array [ Object { - "$id": 0, + "$id": 2, "defs": Array [ Object { "name": Object { - "name": "x", + "name": "precedence1", "range": Array [ - 4, - 14, + 77, + 115, ], "type": "Identifier", }, "node": Object { "range": Array [ - 4, - 14, + 77, + 115, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ - 0, - 15, + 73, + 116, ], "type": "VariableDeclaration", }, @@ -10667,43 +12371,43 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "x", + "name": "precedence1", "range": Array [ - 4, - 14, + 77, + 115, ], "type": "Identifier", }, ], - "name": "x", + "name": "precedence1", "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 4, }, }, Object { - "$id": 1, + "$id": 3, "defs": Array [ Object { "name": Object { - "name": "y", + "name": "precedence2", "range": Array [ - 20, - 36, + 121, + 159, ], "type": "Identifier", }, "node": Object { "range": Array [ - 20, - 36, + 121, + 159, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ - 16, - 37, + 117, + 160, ], "type": "VariableDeclaration", }, @@ -10713,18 +12417,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "y", + "name": "precedence2", "range": Array [ - 20, - 36, + 121, + 159, ], "type": "Identifier", }, ], - "name": "y", + "name": "precedence2", "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 4, }, }, ], @@ -10738,368 +12442,456 @@ Object { "upperScope": null, "variableMap": Object {}, "variableScope": Object { - "$ref": 3, + "$ref": 5, }, "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-typeof.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-union-type.src.ts 1`] = ` Object { - "$id": 3, + "$id": 1, "block": Object { "range": Array [ 0, - 19, + 27, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 2, + "$id": 0, "block": Object { "range": Array [ 0, - 19, + 27, ], "type": "Program", }, "childScopes": Array [], "functionExpressionScope": false, "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "module", + "upperScope": Object { + "$ref": 1, + }, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 1, + }, + "variables": Array [], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/535.ts 1`] = ` +Object { + "$id": 5, + "block": Object { + "range": Array [ + 0, + 52, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 4, + "block": Object { + "range": Array [ + 0, + 51, + ], + "type": "FunctionDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, "references": Array [ Object { - "$id": 1, + "$id": 3, "from": Object { - "$ref": 2, + "$ref": 4, }, "identifier": Object { - "name": "y", + "name": "bar", "range": Array [ - 14, - 15, + 45, + 48, ], "type": "Identifier", }, "kind": "r", - "resolved": null, + "resolved": Object { + "$ref": 2, + }, "writeExpr": undefined, }, ], - "throughReferences": Array [ - Object { - "$ref": 1, - }, - ], - "type": "module", + "throughReferences": Array [], + "type": "function", "upperScope": Object { - "$ref": 3, + "$ref": 5, }, "variableMap": Object { - "x": Object { - "$ref": 0, + "arguments": Object { + "$ref": 1, + }, + "bar": Object { + "$ref": 2, }, }, "variableScope": Object { - "$ref": 2, + "$ref": 4, }, "variables": Array [ Object { - "$id": 0, + "$id": 1, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + Object { + "$id": 2, "defs": Array [ Object { "name": Object { - "name": "x", + "name": "bar", "range": Array [ - 4, - 17, + 15, + 18, ], "type": "Identifier", }, "node": Object { - "range": Array [ - 4, - 17, - ], - "type": "VariableDeclarator", - }, - "parent": Object { "range": Array [ 0, - 18, + 51, ], - "type": "VariableDeclaration", + "type": "FunctionDeclaration", }, - "type": "Variable", + "parent": null, + "type": "Parameter", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "x", + "name": "bar", "range": Array [ - 4, - 17, + 15, + 18, ], "type": "Identifier", }, ], - "name": "x", - "references": Array [], + "name": "bar", + "references": Array [ + Object { + "$ref": 3, + }, + ], "scope": Object { - "$ref": 2, + "$ref": 4, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 51, + ], + "type": "FunctionDeclaration", }, + "parent": null, + "type": "FunctionName", }, ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + ], + "name": "foo", + "references": Array [], + "scope": Object { + "$ref": 5, + }, }, ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [ - Object { - "$ref": 1, - }, - ], - "type": "global", - "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 3, - }, - "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-union-intersection.src.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/abstract-class.ts 1`] = ` Object { - "$id": 5, + "$id": 3, "block": Object { "range": Array [ 0, - 161, + 69, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 4, + "$id": 2, "block": Object { "range": Array [ 0, - 161, + 68, ], - "type": "Program", + "type": "ClassDeclaration", }, "childScopes": Array [], "functionExpressionScope": false, "isStrict": true, "references": Array [], "throughReferences": Array [], - "type": "module", + "type": "class", "upperScope": Object { - "$ref": 5, + "$ref": 3, }, "variableMap": Object { - "intersection": Object { + "A": Object { "$ref": 1, }, - "precedence1": Object { - "$ref": 2, - }, - "precedence2": Object { - "$ref": 3, - }, - "union": Object { - "$ref": 0, - }, }, "variableScope": Object { - "$ref": 4, + "$ref": 3, }, "variables": Array [ Object { - "$id": 0, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "union", + "name": "A", "range": Array [ - 4, - 36, + 15, + 16, ], "type": "Identifier", }, "node": Object { - "range": Array [ - 4, - 36, - ], - "type": "VariableDeclarator", - }, - "parent": Object { "range": Array [ 0, - 37, + 68, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": undefined, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "union", + "name": "A", "range": Array [ - 4, - 36, + 15, + 16, ], "type": "Identifier", }, ], - "name": "union", + "name": "A", "references": Array [], "scope": Object { - "$ref": 4, + "$ref": 2, }, }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "A": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ 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, + "name": Object { + "name": "A", + "range": Array [ + 15, + 16, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 68, + ], + "type": "ClassDeclaration", }, + "parent": null, + "type": "ClassName", }, + ], + "eslintUsed": undefined, + "identifiers": Array [ 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": "A", + "range": Array [ + 15, + 16, ], - "name": "precedence1", - "references": Array [], - "scope": Object { - "$ref": 4, - }, + "type": "Identifier", + }, + ], + "name": "A", + "references": Array [], + "scope": Object { + "$ref": 3, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-implements.ts 1`] = ` +Object { + "$id": 3, + "block": Object { + "range": Array [ + 0, + 83, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 82, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "class", + "upperScope": Object { + "$ref": 3, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, }, + }, + "variableScope": Object { + "$ref": 3, + }, + "variables": Array [ Object { - "$id": 3, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "precedence2", + "name": "Foo", "range": Array [ - 121, - 159, + 6, + 9, ], "type": "Identifier", }, "node": Object { "range": Array [ - 121, - 159, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 117, - 160, + 0, + 82, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": undefined, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "precedence2", + "name": "Foo", "range": Array [ - 121, - 159, + 6, + 9, ], "type": "Identifier", }, ], - "name": "precedence2", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 4, + "$ref": 2, }, }, ], @@ -11111,178 +12903,181 @@ Object { "throughReferences": Array [], "type": "global", "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 5, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, }, - "variables": Array [], -} -`; - -exports[`TypeScript scope analysis sourceType: module tests/fixtures/scope-analysis/types-union-type.src.ts 1`] = ` -Object { - "$id": 1, - "block": Object { - "range": Array [ - 0, - 27, - ], - "type": "Program", + "variableScope": Object { + "$ref": 3, }, - "childScopes": Array [ + "variables": Array [ Object { "$id": 0, - "block": Object { - "range": Array [ - 0, - 27, - ], - "type": "Program", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 82, + ], + "type": "ClassDeclaration", + }, + "parent": null, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + ], + "name": "Foo", "references": Array [], - "throughReferences": Array [], - "type": "module", - "upperScope": Object { - "$ref": 1, - }, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 0, + "scope": Object { + "$ref": 3, }, - "variables": Array [], }, ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object {}, - "variableScope": Object { - "$ref": 1, - }, - "variables": Array [], } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/535.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-properties.ts 1`] = ` Object { - "$id": 5, + "$id": 8, "block": Object { "range": Array [ 0, - 52, + 63, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 4, + "$id": 7, "block": Object { "range": Array [ - 0, - 51, + 19, + 62, ], - "type": "FunctionDeclaration", + "type": "ClassDeclaration", }, "childScopes": Array [], "functionExpressionScope": false, - "isStrict": false, + "isStrict": true, "references": Array [ Object { - "$id": 3, + "$id": 5, "from": Object { - "$ref": 4, + "$ref": 7, }, "identifier": Object { - "name": "bar", + "name": "s", "range": Array [ - 45, - 48, + 43, + 44, ], "type": "Identifier", }, "kind": "r", "resolved": Object { - "$ref": 2, + "$ref": 0, + }, + "writeExpr": undefined, + }, + Object { + "$id": 6, + "from": Object { + "$ref": 7, + }, + "identifier": Object { + "name": "s", + "range": Array [ + 50, + 51, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, }, "writeExpr": undefined, }, ], - "throughReferences": Array [], - "type": "function", + "throughReferences": Array [ + Object { + "$ref": 5, + }, + Object { + "$ref": 6, + }, + ], + "type": "class", "upperScope": Object { - "$ref": 5, + "$ref": 8, }, "variableMap": Object { - "arguments": Object { - "$ref": 1, - }, - "bar": Object { - "$ref": 2, + "A": Object { + "$ref": 4, }, }, "variableScope": Object { - "$ref": 4, + "$ref": 8, }, "variables": Array [ Object { - "$id": 1, - "defs": Array [], - "eslintUsed": undefined, - "identifiers": Array [], - "name": "arguments", - "references": Array [], - "scope": Object { - "$ref": 4, - }, - }, - Object { - "$id": 2, + "$id": 4, "defs": Array [ Object { "name": Object { - "name": "bar", + "name": "A", "range": Array [ - 15, - 18, + 25, + 26, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 51, + 19, + 62, ], - "type": "FunctionDeclaration", + "type": "ClassDeclaration", }, - "parent": null, - "type": "Parameter", + "parent": undefined, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "bar", + "name": "A", "range": Array [ - 15, - 18, + 25, + 26, ], "type": "Identifier", }, ], - "name": "bar", - "references": Array [ - Object { - "$ref": 3, - }, - ], + "name": "A", + "references": Array [], "scope": Object { - "$ref": 4, + "$ref": 7, }, }, ], @@ -11290,17 +13085,67 @@ Object { ], "functionExpressionScope": false, "isStrict": false, - "references": Array [], - "throughReferences": Array [], + "references": Array [ + Object { + "$id": 2, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 10, + 18, + ], + "type": "CallExpression", + }, + }, + Object { + "$id": 3, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "Symbol", + "range": Array [ + 10, + 16, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], "type": "global", "upperScope": null, "variableMap": Object { - "foo": Object { + "A": Object { + "$ref": 1, + }, + "s": Object { "$ref": 0, }, }, "variableScope": Object { - "$ref": 5, + "$ref": 8, }, "variables": Array [ Object { @@ -11308,62 +13153,118 @@ Object { "defs": Array [ Object { "name": Object { - "name": "foo", + "name": "s", "range": Array [ - 9, - 12, + 6, + 7, ], "type": "Identifier", }, "node": Object { + "range": Array [ + 6, + 18, + ], + "type": "VariableDeclarator", + }, + "parent": Object { "range": Array [ 0, - 51, + 18, ], - "type": "FunctionDeclaration", + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "s", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + ], + "name": "s", + "references": Array [ + Object { + "$ref": 2, + }, + Object { + "$ref": 5, + }, + Object { + "$ref": 6, + }, + ], + "scope": Object { + "$ref": 8, + }, + }, + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "A", + "range": Array [ + 25, + 26, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 19, + 62, + ], + "type": "ClassDeclaration", }, "parent": null, - "type": "FunctionName", + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "foo", + "name": "A", "range": Array [ - 9, - 12, + 25, + 26, ], "type": "Identifier", }, ], - "name": "foo", + "name": "A", "references": Array [], "scope": Object { - "$ref": 5, + "$ref": 8, }, }, ], } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/abstract-class.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-supper-type.ts 1`] = ` Object { - "$id": 3, + "$id": 12, "block": Object { "range": Array [ 0, - 69, + 117, ], "type": "Program", }, "childScopes": Array [ Object { - "$id": 2, + "$id": 7, "block": Object { "range": Array [ 0, - 68, + 40, ], "type": "ClassDeclaration", }, @@ -11374,33 +13275,33 @@ Object { "throughReferences": Array [], "type": "class", "upperScope": Object { - "$ref": 3, + "$ref": 12, }, "variableMap": Object { - "A": Object { - "$ref": 1, + "Foo": Object { + "$ref": 6, }, }, "variableScope": Object { - "$ref": 3, + "$ref": 12, }, "variables": Array [ Object { - "$id": 1, + "$id": 6, "defs": Array [ Object { "name": Object { - "name": "A", + "name": "Foo", "range": Array [ 15, - 16, + 18, ], "type": "Identifier", }, "node": Object { "range": Array [ 0, - 68, + 40, ], "type": "ClassDeclaration", }, @@ -11411,99 +13312,97 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "A", + "name": "Foo", "range": Array [ 15, - 16, + 18, ], "type": "Identifier", }, ], - "name": "A", + "name": "Foo", "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 7, }, }, ], }, - ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object { - "A": Object { - "$ref": 0, - }, - }, - "variableScope": Object { - "$ref": 3, - }, - "variables": Array [ Object { - "$id": 0, - "defs": Array [ - Object { - "name": Object { - "name": "A", - "range": Array [ - 15, - 16, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 0, - 68, - ], - "type": "ClassDeclaration", - }, - "parent": null, - "type": "ClassName", + "$id": 9, + "block": Object { + "range": Array [ + 42, + 82, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [], + "type": "class", + "upperScope": Object { + "$ref": 12, + }, + "variableMap": Object { + "Foo2": Object { + "$ref": 8, }, - ], - "eslintUsed": undefined, - "identifiers": Array [ + }, + "variableScope": Object { + "$ref": 12, + }, + "variables": Array [ Object { - "name": "A", - "range": Array [ - 15, - 16, + "$id": 8, + "defs": Array [ + Object { + "name": Object { + "name": "Foo2", + "range": Array [ + 56, + 60, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 42, + 82, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, ], - "type": "Identifier", + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo2", + "range": Array [ + 56, + 60, + ], + "type": "Identifier", + }, + ], + "name": "Foo2", + "references": Array [], + "scope": Object { + "$ref": 9, + }, }, ], - "name": "A", - "references": Array [], - "scope": Object { - "$ref": 3, - }, }, - ], -} -`; - -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-implements.ts 1`] = ` -Object { - "$id": 3, - "block": Object { - "range": Array [ - 0, - 83, - ], - "type": "Program", - }, - "childScopes": Array [ Object { - "$id": 2, + "$id": 11, "block": Object { "range": Array [ - 0, - 82, + 84, + 116, ], "type": "ClassDeclaration", }, @@ -11514,33 +13413,33 @@ Object { "throughReferences": Array [], "type": "class", "upperScope": Object { - "$ref": 3, + "$ref": 12, }, "variableMap": Object { - "Foo": Object { - "$ref": 1, + "Foo3": Object { + "$ref": 10, }, }, "variableScope": Object { - "$ref": 3, + "$ref": 12, }, "variables": Array [ Object { - "$id": 1, + "$id": 10, "defs": Array [ Object { "name": Object { - "name": "Foo", + "name": "Foo3", "range": Array [ - 6, - 9, + 90, + 94, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 82, + 84, + 116, ], "type": "ClassDeclaration", }, @@ -11551,18 +13450,18 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "Foo", + "name": "Foo3", "range": Array [ - 6, - 9, + 90, + 94, ], "type": "Identifier", }, ], - "name": "Foo", + "name": "Foo3", "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 11, }, }, ], @@ -11570,17 +13469,85 @@ Object { ], "functionExpressionScope": false, "isStrict": false, - "references": Array [], - "throughReferences": Array [], + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 12, + }, + "identifier": Object { + "name": "Bar", + "range": Array [ + 27, + 30, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + Object { + "$id": 4, + "from": Object { + "$ref": 12, + }, + "identifier": Object { + "name": "Bar", + "range": Array [ + 69, + 72, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + Object { + "$id": 5, + "from": Object { + "$ref": 12, + }, + "identifier": Object { + "name": "Bar", + "range": Array [ + 103, + 106, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + Object { + "$ref": 4, + }, + Object { + "$ref": 5, + }, + ], "type": "global", "upperScope": null, "variableMap": Object { "Foo": Object { "$ref": 0, }, + "Foo2": Object { + "$ref": 1, + }, + "Foo3": Object { + "$ref": 2, + }, }, "variableScope": Object { - "$ref": 3, + "$ref": 12, }, "variables": Array [ Object { @@ -11590,15 +13557,15 @@ Object { "name": Object { "name": "Foo", "range": Array [ - 6, - 9, + 15, + 18, ], "type": "Identifier", }, "node": Object { "range": Array [ 0, - 82, + 40, ], "type": "ClassDeclaration", }, @@ -11611,8 +13578,8 @@ Object { Object { "name": "Foo", "range": Array [ - 6, - 9, + 15, + 18, ], "type": "Identifier", }, @@ -11620,140 +13587,104 @@ Object { "name": "Foo", "references": Array [], "scope": Object { - "$ref": 3, + "$ref": 12, }, }, - ], -} -`; - -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-properties.ts 1`] = ` -Object { - "$id": 8, - "block": Object { - "range": Array [ - 0, - 63, - ], - "type": "Program", - }, - "childScopes": Array [ Object { - "$id": 7, - "block": Object { - "range": Array [ - 19, - 62, - ], - "type": "ClassDeclaration", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [ + "$id": 1, + "defs": Array [ Object { - "$id": 5, - "from": Object { - "$ref": 7, - }, - "identifier": Object { - "name": "s", + "name": Object { + "name": "Foo2", "range": Array [ - 43, - 44, + 56, + 60, ], "type": "Identifier", }, - "kind": "r", - "resolved": Object { - "$ref": 0, + "node": Object { + "range": Array [ + 42, + 82, + ], + "type": "ClassDeclaration", }, - "writeExpr": undefined, + "parent": null, + "type": "ClassName", }, + ], + "eslintUsed": undefined, + "identifiers": Array [ Object { - "$id": 6, - "from": Object { - "$ref": 7, - }, - "identifier": Object { - "name": "s", + "name": "Foo2", + "range": Array [ + 56, + 60, + ], + "type": "Identifier", + }, + ], + "name": "Foo2", + "references": Array [], + "scope": Object { + "$ref": 12, + }, + }, + Object { + "$id": 2, + "defs": Array [ + Object { + "name": Object { + "name": "Foo3", "range": Array [ - 50, - 51, + 90, + 94, ], "type": "Identifier", }, - "kind": "r", - "resolved": Object { - "$ref": 0, + "node": Object { + "range": Array [ + 84, + 116, + ], + "type": "ClassDeclaration", }, - "writeExpr": undefined, - }, - ], - "throughReferences": Array [ - Object { - "$ref": 5, - }, - Object { - "$ref": 6, + "parent": null, + "type": "ClassName", }, ], - "type": "class", - "upperScope": Object { - "$ref": 8, - }, - "variableMap": Object { - "A": Object { - "$ref": 4, - }, - }, - "variableScope": Object { - "$ref": 8, - }, - "variables": Array [ + "eslintUsed": undefined, + "identifiers": Array [ Object { - "$id": 4, - "defs": Array [ - Object { - "name": Object { - "name": "A", - "range": Array [ - 25, - 26, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 19, - 62, - ], - "type": "ClassDeclaration", - }, - "parent": undefined, - "type": "ClassName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "A", - "range": Array [ - 25, - 26, - ], - "type": "Identifier", - }, + "name": "Foo3", + "range": Array [ + 90, + 94, ], - "name": "A", - "references": Array [], - "scope": Object { - "$ref": 7, - }, + "type": "Identifier", }, ], + "name": "Foo3", + "references": Array [], + "scope": Object { + "$ref": 12, + }, }, ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/computed-properties-in-interface.ts 1`] = ` +Object { + "$id": 8, + "block": Object { + "range": Array [ + 0, + 110, + ], + "type": "Program", + }, + "childScopes": Array [], "functionExpressionScope": false, "isStrict": false, "references": Array [ @@ -11763,10 +13694,10 @@ Object { "$ref": 8, }, "identifier": Object { - "name": "s", + "name": "s1", "range": Array [ 6, - 7, + 8, ], "type": "Identifier", }, @@ -11776,8 +13707,8 @@ Object { }, "writeExpr": Object { "range": Array [ - 10, - 18, + 11, + 19, ], "type": "CallExpression", }, @@ -11790,8 +13721,50 @@ Object { "identifier": Object { "name": "Symbol", "range": Array [ - 10, - 16, + 11, + 17, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + Object { + "$id": 4, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s2", + "range": Array [ + 21, + 23, + ], + "type": "Identifier", + }, + "kind": "w", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": Object { + "range": Array [ + 26, + 34, + ], + "type": "CallExpression", + }, + }, + Object { + "$id": 5, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "Symbol", + "range": Array [ + 26, + 32, ], "type": "Identifier", }, @@ -11799,21 +13772,62 @@ Object { "resolved": null, "writeExpr": undefined, }, + Object { + "$id": 6, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s1", + "range": Array [ + 54, + 56, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + Object { + "$id": 7, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s2", + "range": Array [ + 71, + 73, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 1, + }, + "writeExpr": undefined, + }, ], "throughReferences": Array [ Object { "$ref": 3, }, + Object { + "$ref": 5, + }, ], "type": "global", "upperScope": null, "variableMap": Object { - "A": Object { - "$ref": 1, - }, - "s": Object { + "s1": Object { "$ref": 0, }, + "s2": Object { + "$ref": 1, + }, }, "variableScope": Object { "$ref": 8, @@ -11824,24 +13838,24 @@ Object { "defs": Array [ Object { "name": Object { - "name": "s", + "name": "s1", "range": Array [ 6, - 7, + 8, ], "type": "Identifier", }, "node": Object { "range": Array [ 6, - 18, + 19, ], "type": "VariableDeclarator", }, "parent": Object { "range": Array [ 0, - 18, + 34, ], "type": "VariableDeclaration", }, @@ -11851,22 +13865,19 @@ Object { "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "s", + "name": "s1", "range": Array [ 6, - 7, + 8, ], "type": "Identifier", }, ], - "name": "s", + "name": "s1", "references": Array [ Object { "$ref": 2, }, - Object { - "$ref": 5, - }, Object { "$ref": 6, }, @@ -11880,37 +13891,50 @@ Object { "defs": Array [ Object { "name": Object { - "name": "A", + "name": "s2", "range": Array [ - 25, - 26, + 21, + 23, ], "type": "Identifier", }, "node": Object { "range": Array [ - 19, - 62, + 21, + 34, ], - "type": "ClassDeclaration", + "type": "VariableDeclarator", }, - "parent": null, - "type": "ClassName", + "parent": Object { + "range": Array [ + 0, + 34, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "A", + "name": "s2", "range": Array [ - 25, - 26, + 21, + 23, ], "type": "Identifier", }, ], - "name": "A", - "references": Array [], + "name": "s2", + "references": Array [ + Object { + "$ref": 4, + }, + Object { + "$ref": 7, + }, + ], "scope": Object { "$ref": 8, }, @@ -11919,238 +13943,97 @@ Object { } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/class-supper-type.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/computed-properties-in-type.ts 1`] = ` Object { - "$id": 12, + "$id": 8, "block": Object { "range": Array [ 0, - 117, + 107, ], "type": "Program", }, - "childScopes": Array [ + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ Object { - "$id": 7, - "block": Object { + "$id": 2, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s1", "range": Array [ - 0, - 40, + 6, + 8, ], - "type": "ClassDeclaration", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "class", - "upperScope": Object { - "$ref": 12, + "type": "Identifier", }, - "variableMap": Object { - "Foo": Object { - "$ref": 6, - }, + "kind": "w", + "resolved": Object { + "$ref": 0, }, - "variableScope": Object { - "$ref": 12, + "writeExpr": Object { + "range": Array [ + 11, + 19, + ], + "type": "CallExpression", }, - "variables": Array [ - Object { - "$id": 6, - "defs": Array [ - Object { - "name": Object { - "name": "Foo", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 0, - 40, - ], - "type": "ClassDeclaration", - }, - "parent": undefined, - "type": "ClassName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "Foo", - "range": Array [ - 15, - 18, - ], - "type": "Identifier", - }, - ], - "name": "Foo", - "references": Array [], - "scope": Object { - "$ref": 7, - }, - }, - ], }, Object { - "$id": 9, - "block": Object { + "$id": 3, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "Symbol", "range": Array [ - 42, - 82, + 11, + 17, ], - "type": "ClassDeclaration", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "class", - "upperScope": Object { - "$ref": 12, - }, - "variableMap": Object { - "Foo2": Object { - "$ref": 8, - }, - }, - "variableScope": Object { - "$ref": 12, + "type": "Identifier", }, - "variables": Array [ - Object { - "$id": 8, - "defs": Array [ - Object { - "name": Object { - "name": "Foo2", - "range": Array [ - 56, - 60, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 42, - 82, - ], - "type": "ClassDeclaration", - }, - "parent": undefined, - "type": "ClassName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "Foo2", - "range": Array [ - 56, - 60, - ], - "type": "Identifier", - }, - ], - "name": "Foo2", - "references": Array [], - "scope": Object { - "$ref": 9, - }, - }, - ], + "kind": "r", + "resolved": null, + "writeExpr": undefined, }, Object { - "$id": 11, - "block": Object { + "$id": 4, + "from": Object { + "$ref": 8, + }, + "identifier": Object { + "name": "s2", "range": Array [ - 84, - 116, + 21, + 23, ], - "type": "ClassDeclaration", - }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": true, - "references": Array [], - "throughReferences": Array [], - "type": "class", - "upperScope": Object { - "$ref": 12, - }, - "variableMap": Object { - "Foo3": Object { - "$ref": 10, - }, + "type": "Identifier", }, - "variableScope": Object { - "$ref": 12, + "kind": "w", + "resolved": Object { + "$ref": 1, }, - "variables": Array [ - Object { - "$id": 10, - "defs": Array [ - Object { - "name": Object { - "name": "Foo3", - "range": Array [ - 90, - 94, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 84, - 116, - ], - "type": "ClassDeclaration", - }, - "parent": undefined, - "type": "ClassName", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "Foo3", - "range": Array [ - 90, - 94, - ], - "type": "Identifier", - }, - ], - "name": "Foo3", - "references": Array [], - "scope": Object { - "$ref": 11, - }, - }, - ], - }, - ], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [ + "writeExpr": Object { + "range": Array [ + 26, + 34, + ], + "type": "CallExpression", + }, + }, Object { - "$id": 3, + "$id": 5, "from": Object { - "$ref": 12, + "$ref": 8, }, "identifier": Object { - "name": "Bar", + "name": "Symbol", "range": Array [ - 27, - 30, + 26, + 32, ], "type": "Identifier", }, @@ -12159,37 +14042,41 @@ Object { "writeExpr": undefined, }, Object { - "$id": 4, + "$id": 6, "from": Object { - "$ref": 12, + "$ref": 8, }, "identifier": Object { - "name": "Bar", + "name": "s1", "range": Array [ - 69, - 72, + 51, + 53, ], "type": "Identifier", }, "kind": "r", - "resolved": null, + "resolved": Object { + "$ref": 0, + }, "writeExpr": undefined, }, Object { - "$id": 5, + "$id": 7, "from": Object { - "$ref": 12, + "$ref": 8, }, "identifier": Object { - "name": "Bar", + "name": "s2", "range": Array [ - 103, - 106, + 68, + 70, ], "type": "Identifier", }, "kind": "r", - "resolved": null, + "resolved": Object { + "$ref": 1, + }, "writeExpr": undefined, }, ], @@ -12197,9 +14084,6 @@ Object { Object { "$ref": 3, }, - Object { - "$ref": 4, - }, Object { "$ref": 5, }, @@ -12207,18 +14091,15 @@ Object { "type": "global", "upperScope": null, "variableMap": Object { - "Foo": Object { + "s1": Object { "$ref": 0, }, - "Foo2": Object { + "s2": Object { "$ref": 1, }, - "Foo3": Object { - "$ref": 2, - }, }, "variableScope": Object { - "$ref": 12, + "$ref": 8, }, "variables": Array [ Object { @@ -12226,39 +14107,52 @@ Object { "defs": Array [ Object { "name": Object { - "name": "Foo", + "name": "s1", "range": Array [ - 15, - 18, + 6, + 8, ], "type": "Identifier", }, "node": Object { + "range": Array [ + 6, + 19, + ], + "type": "VariableDeclarator", + }, + "parent": Object { "range": Array [ 0, - 40, + 34, ], - "type": "ClassDeclaration", + "type": "VariableDeclaration", }, - "parent": null, - "type": "ClassName", + "type": "Variable", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "Foo", + "name": "s1", "range": Array [ - 15, - 18, + 6, + 8, ], "type": "Identifier", }, ], - "name": "Foo", - "references": Array [], + "name": "s1", + "references": Array [ + Object { + "$ref": 2, + }, + Object { + "$ref": 6, + }, + ], "scope": Object { - "$ref": 12, + "$ref": 8, }, }, Object { @@ -12266,193 +14160,456 @@ Object { "defs": Array [ Object { "name": Object { - "name": "Foo2", + "name": "s2", "range": Array [ - 56, - 60, + 21, + 23, ], "type": "Identifier", }, "node": Object { "range": Array [ - 42, - 82, + 21, + 34, ], - "type": "ClassDeclaration", + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 34, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "s2", + "range": Array [ + 21, + 23, + ], + "type": "Identifier", + }, + ], + "name": "s2", + "references": Array [ + Object { + "$ref": 4, + }, + Object { + "$ref": 7, + }, + ], + "scope": Object { + "$ref": 8, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-function.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 40, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 2, + }, + "identifier": Object { + "name": "f", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "f": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ + Object { + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "f", + "range": Array [ + 17, + 18, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 0, + 37, + ], + "type": "TSDeclareFunction", }, "parent": null, - "type": "ClassName", + "type": "FunctionName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "Foo2", + "name": "f", "range": Array [ - 56, - 60, + 17, + 18, ], "type": "Identifier", }, ], - "name": "Foo2", - "references": Array [], + "name": "f", + "references": Array [ + Object { + "$ref": 1, + }, + ], "scope": Object { - "$ref": 12, + "$ref": 2, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-global.ts 1`] = ` +Object { + "$id": 2, + "block": Object { + "range": Array [ + 0, + 55, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 1, + "from": Object { + "$ref": 2, + }, + "identifier": Object { + "name": "C", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", }, + "kind": "w", + "resolved": Object { + "$ref": 0, + }, + "writeExpr": Object { + "range": Array [ + 42, + 43, + ], + "type": "Literal", + }, + }, + ], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "C": Object { + "$ref": 0, }, + }, + "variableScope": Object { + "$ref": 2, + }, + "variables": Array [ Object { - "$id": 2, + "$id": 0, "defs": Array [ Object { "name": Object { - "name": "Foo3", + "name": "C", "range": Array [ - 90, - 94, + 25, + 34, ], "type": "Identifier", }, "node": Object { "range": Array [ - 84, - 116, + 25, + 34, ], - "type": "ClassDeclaration", + "type": "VariableDeclarator", }, - "parent": null, - "type": "ClassName", + "parent": Object { + "range": Array [ + 21, + 34, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", }, ], - "eslintUsed": undefined, + "eslintUsed": true, "identifiers": Array [ Object { - "name": "Foo3", + "name": "C", "range": Array [ - 90, - 94, + 25, + 34, ], "type": "Identifier", }, ], - "name": "Foo3", - "references": Array [], + "name": "C", + "references": Array [ + Object { + "$ref": 1, + }, + ], "scope": Object { - "$ref": 12, + "$ref": 2, }, }, ], } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/computed-properties-in-interface.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-module.ts 1`] = ` Object { - "$id": 8, + "$id": 7, "block": Object { "range": Array [ 0, - 110, + 95, ], "type": "Program", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [ + "childScopes": Array [ Object { - "$id": 2, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "s1", + "$id": 6, + "block": Object { "range": Array [ - 6, - 8, + 33, + 92, ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 0, + "type": "TSModuleBlock", }, - "writeExpr": Object { - "range": Array [ - 11, - 19, - ], - "type": "CallExpression", + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ + Object { + "$id": 5, + "from": Object { + "$ref": 6, + }, + "identifier": Object { + "name": "a", + "range": Array [ + 89, + 90, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": Object { + "$ref": 3, + }, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [], + "type": "block", + "upperScope": Object { + "$ref": 7, }, - }, - Object { - "$id": 3, - "from": Object { - "$ref": 8, + "variableMap": Object { + "a": Object { + "$ref": 3, + }, + "b": Object { + "$ref": 4, + }, }, - "identifier": Object { - "name": "Symbol", - "range": Array [ - 11, - 17, - ], - "type": "Identifier", + "variableScope": Object { + "$ref": 7, }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, + "variables": Array [ + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 52, + 61, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 52, + 61, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 46, + 61, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 52, + 61, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [ + Object { + "$ref": 5, + }, + ], + "scope": Object { + "$ref": 6, + }, + }, + Object { + "$id": 4, + "defs": Array [ + Object { + "name": Object { + "name": "b", + "range": Array [ + 79, + 90, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 79, + 90, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 73, + 90, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "b", + "range": Array [ + 79, + 90, + ], + "type": "Identifier", + }, + ], + "name": "b", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [ Object { - "$id": 4, + "$id": 1, "from": Object { - "$ref": 8, + "$ref": 7, }, "identifier": Object { - "name": "s2", + "name": "a", "range": Array [ - 21, - 23, + 6, + 7, ], "type": "Identifier", }, "kind": "w", "resolved": Object { - "$ref": 1, + "$ref": 0, }, "writeExpr": Object { "range": Array [ - 26, - 34, - ], - "type": "CallExpression", - }, - }, - Object { - "$id": 5, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "Symbol", - "range": Array [ - 26, - 32, + 10, + 11, ], - "type": "Identifier", + "type": "Literal", }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, }, Object { - "$id": 6, + "$id": 2, "from": Object { - "$ref": 8, + "$ref": 7, }, "identifier": Object { - "name": "s1", + "name": "a", "range": Array [ - 54, - 56, + 93, + 94, ], "type": "Identifier", }, @@ -12462,46 +14619,241 @@ Object { }, "writeExpr": undefined, }, + ], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object { + "a": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ Object { - "$id": 7, - "from": Object { - "$ref": 8, + "$id": 0, + "defs": Array [ + Object { + "name": Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 6, + 11, + ], + "type": "VariableDeclarator", + }, + "parent": Object { + "range": Array [ + 0, + 11, + ], + "type": "VariableDeclaration", + }, + "type": "Variable", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + ], + "name": "a", + "references": Array [ + Object { + "$ref": 1, + }, + Object { + "$ref": 2, + }, + ], + "scope": Object { + "$ref": 7, }, - "identifier": Object { - "name": "s2", + }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/decorator-parameter-property-array.ts 1`] = ` +Object { + "$id": 6, + "block": Object { + "range": Array [ + 0, + 65, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 5, + "block": Object { "range": Array [ - 71, - 73, + 15, + 64, ], - "type": "Identifier", + "type": "ClassDeclaration", }, - "kind": "r", - "resolved": Object { - "$ref": 1, + "childScopes": Array [ + Object { + "$id": 4, + "block": Object { + "range": Array [ + 40, + 62, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 4, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 5, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 6, }, - "writeExpr": undefined, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 6, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 64, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], }, ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], "throughReferences": Array [ Object { "$ref": 3, }, - Object { - "$ref": 5, - }, ], "type": "global", "upperScope": null, "variableMap": Object { - "s1": Object { + "Foo": Object { "$ref": 0, }, - "s2": Object { - "$ref": 1, - }, }, "variableScope": Object { - "$ref": 8, + "$ref": 6, }, "variables": Array [ Object { @@ -12509,268 +14861,464 @@ Object { "defs": Array [ Object { "name": Object { - "name": "s1", + "name": "Foo", "range": Array [ - 6, - 8, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 6, - 19, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 0, - 34, + 15, + 64, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "s1", + "name": "Foo", "range": Array [ - 6, - 8, + 21, + 24, ], "type": "Identifier", }, ], - "name": "s1", - "references": Array [ + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/decorator-parameter-property-identifier.ts 1`] = ` +Object { + "$id": 7, + "block": Object { + "range": Array [ + 0, + 65, + ], + "type": "Program", + }, + "childScopes": Array [ + Object { + "$id": 6, + "block": Object { + "range": Array [ + 15, + 64, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [ Object { - "$ref": 2, + "$id": 5, + "block": Object { + "range": Array [ + 40, + 62, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + "test": Object { + "$ref": 3, + }, + }, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "test", + "range": Array [ + 46, + 58, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 40, + 62, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "test", + "range": Array [ + 46, + 58, + ], + "type": "Identifier", + }, + ], + "name": "test", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ Object { - "$ref": 6, + "$ref": 4, }, ], - "scope": Object { - "$ref": 8, + "type": "class", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 7, }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 64, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, + }, + ], }, + ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "global", + "upperScope": null, + "variableMap": Object { + "Foo": Object { + "$ref": 0, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ Object { - "$id": 1, + "$id": 0, "defs": Array [ Object { "name": Object { - "name": "s2", + "name": "Foo", "range": Array [ 21, - 23, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 21, - 34, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 0, - 34, + 15, + 64, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "s2", + "name": "Foo", "range": Array [ 21, - 23, + 24, ], "type": "Identifier", }, ], - "name": "s2", - "references": Array [ - Object { - "$ref": 4, - }, - Object { - "$ref": 7, - }, - ], + "name": "Foo", + "references": Array [], "scope": Object { - "$ref": 8, + "$ref": 7, }, }, ], } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/computed-properties-in-type.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/decorator-parameter-property-object.ts 1`] = ` Object { - "$id": 8, + "$id": 6, "block": Object { "range": Array [ 0, - 107, + 60, ], "type": "Program", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [ - Object { - "$id": 2, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "s1", - "range": Array [ - 6, - 8, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": Object { - "range": Array [ - 11, - 19, - ], - "type": "CallExpression", - }, - }, - Object { - "$id": 3, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "Symbol", - "range": Array [ - 11, - 17, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, - }, - Object { - "$id": 4, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "s2", - "range": Array [ - 21, - 23, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 1, - }, - "writeExpr": Object { - "range": Array [ - 26, - 34, - ], - "type": "CallExpression", - }, - }, + "childScopes": Array [ Object { "$id": 5, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "Symbol", - "range": Array [ - 26, - 32, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": null, - "writeExpr": undefined, - }, - Object { - "$id": 6, - "from": Object { - "$ref": 8, - }, - "identifier": Object { - "name": "s1", + "block": Object { "range": Array [ - 51, - 53, + 15, + 59, ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 0, + "type": "ClassDeclaration", }, - "writeExpr": undefined, - }, - Object { - "$id": 7, - "from": Object { - "$ref": 8, + "childScopes": Array [ + Object { + "$id": 4, + "block": Object { + "range": Array [ + 40, + 57, + ], + "type": "FunctionExpression", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 3, + "from": Object { + "$ref": 4, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 5, + }, + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + }, + "variableScope": Object { + "$ref": 4, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 4, + }, + }, + ], + }, + ], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ + Object { + "$ref": 3, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 6, }, - "identifier": Object { - "name": "s2", - "range": Array [ - 68, - 70, - ], - "type": "Identifier", + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, }, - "kind": "r", - "resolved": Object { - "$ref": 1, + "variableScope": Object { + "$ref": 6, }, - "writeExpr": undefined, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 59, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], }, ], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], "throughReferences": Array [ Object { "$ref": 3, }, - Object { - "$ref": 5, - }, ], "type": "global", "upperScope": null, "variableMap": Object { - "s1": Object { + "Foo": Object { "$ref": 0, }, - "s2": Object { - "$ref": 1, - }, }, "variableScope": Object { - "$ref": 8, + "$ref": 6, }, "variables": Array [ Object { @@ -12778,155 +15326,253 @@ Object { "defs": Array [ Object { "name": Object { - "name": "s1", + "name": "Foo", "range": Array [ - 6, - 8, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 6, - 19, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 0, - 34, + 15, + 59, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "s1", + "name": "Foo", "range": Array [ - 6, - 8, + 21, + 24, ], "type": "Identifier", }, ], - "name": "s1", - "references": Array [ - Object { - "$ref": 2, - }, - Object { - "$ref": 6, - }, - ], + "name": "Foo", + "references": Array [], "scope": Object { - "$ref": 8, + "$ref": 6, }, }, + ], +} +`; + +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/decorator-parameter-property-parameter.ts 1`] = ` +Object { + "$id": 7, + "block": Object { + "range": Array [ + 0, + 82, + ], + "type": "Program", + }, + "childScopes": Array [ Object { - "$id": 1, - "defs": Array [ + "$id": 6, + "block": Object { + "range": Array [ + 15, + 81, + ], + "type": "ClassDeclaration", + }, + "childScopes": Array [ Object { - "name": Object { - "name": "s2", + "$id": 5, + "block": Object { "range": Array [ - 21, - 23, + 40, + 79, ], - "type": "Identifier", + "type": "FunctionExpression", }, - "node": Object { - "range": Array [ - 21, - 34, - ], - "type": "VariableDeclarator", + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, }, - "parent": Object { - "range": Array [ - 0, - 34, - ], - "type": "VariableDeclaration", + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + "test": Object { + "$ref": 3, + }, }, - "type": "Variable", + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "test", + "range": Array [ + 63, + 75, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 40, + 79, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "test", + "range": Array [ + 63, + 75, + ], + "type": "Identifier", + }, + ], + "name": "test", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + ], }, ], - "eslintUsed": undefined, - "identifiers": Array [ + "functionExpressionScope": false, + "isStrict": true, + "references": Array [], + "throughReferences": Array [ Object { - "name": "s2", - "range": Array [ - 21, - 23, + "$ref": 4, + }, + ], + "type": "class", + "upperScope": Object { + "$ref": 7, + }, + "variableMap": Object { + "Foo": Object { + "$ref": 1, + }, + }, + "variableScope": Object { + "$ref": 7, + }, + "variables": Array [ + Object { + "$id": 1, + "defs": Array [ + Object { + "name": Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 15, + 81, + ], + "type": "ClassDeclaration", + }, + "parent": undefined, + "type": "ClassName", + }, ], - "type": "Identifier", - }, - ], - "name": "s2", - "references": Array [ - Object { - "$ref": 4, - }, - Object { - "$ref": 7, + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + ], + "name": "Foo", + "references": Array [], + "scope": Object { + "$ref": 6, + }, }, ], - "scope": Object { - "$ref": 8, - }, }, ], -} -`; - -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-function.ts 1`] = ` -Object { - "$id": 2, - "block": Object { - "range": Array [ - 0, - 40, - ], - "type": "Program", - }, - "childScopes": Array [], "functionExpressionScope": false, "isStrict": false, - "references": Array [ + "references": Array [], + "throughReferences": Array [ Object { - "$id": 1, - "from": Object { - "$ref": 2, - }, - "identifier": Object { - "name": "f", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": undefined, + "$ref": 4, }, ], - "throughReferences": Array [], "type": "global", "upperScope": null, "variableMap": Object { - "f": Object { + "Foo": Object { "$ref": 0, }, }, "variableScope": Object { - "$ref": 2, + "$ref": 7, }, "variables": Array [ Object { @@ -12934,210 +15580,187 @@ Object { "defs": Array [ Object { "name": Object { - "name": "f", + "name": "Foo", "range": Array [ - 17, - 18, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 0, - 37, + 15, + 81, ], - "type": "TSDeclareFunction", + "type": "ClassDeclaration", }, "parent": null, - "type": "FunctionName", + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "f", + "name": "Foo", "range": Array [ - 17, - 18, + 21, + 24, ], "type": "Identifier", }, ], - "name": "f", - "references": Array [ - Object { - "$ref": 1, - }, - ], + "name": "Foo", + "references": Array [], "scope": Object { - "$ref": 2, + "$ref": 7, }, }, ], } `; -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-global.ts 1`] = ` +exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/decorator-parameter-property-rest.ts 1`] = ` Object { - "$id": 2, + "$id": 7, "block": Object { "range": Array [ 0, - 55, + 70, ], "type": "Program", }, - "childScopes": Array [], - "functionExpressionScope": false, - "isStrict": false, - "references": Array [ + "childScopes": Array [ Object { - "$id": 1, - "from": Object { - "$ref": 2, - }, - "identifier": Object { - "name": "C", - "range": Array [ - 38, - 39, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": Object { + "$id": 6, + "block": Object { "range": Array [ - 42, - 43, + 15, + 69, ], - "type": "Literal", + "type": "ClassDeclaration", }, - }, - ], - "throughReferences": Array [], - "type": "global", - "upperScope": null, - "variableMap": Object { - "C": Object { - "$ref": 0, - }, - }, - "variableScope": Object { - "$ref": 2, - }, - "variables": Array [ - Object { - "$id": 0, - "defs": Array [ + "childScopes": Array [ Object { - "name": Object { - "name": "C", + "$id": 5, + "block": Object { "range": Array [ - 25, - 34, + 40, + 67, ], - "type": "Identifier", + "type": "FunctionExpression", }, - "node": Object { - "range": Array [ - 25, - 34, - ], - "type": "VariableDeclarator", + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": true, + "references": Array [ + Object { + "$id": 4, + "from": Object { + "$ref": 5, + }, + "identifier": Object { + "name": "Dec", + "range": Array [ + 42, + 45, + ], + "type": "Identifier", + }, + "kind": "r", + "resolved": null, + "writeExpr": undefined, + }, + ], + "throughReferences": Array [ + Object { + "$ref": 4, + }, + ], + "type": "function", + "upperScope": Object { + "$ref": 6, }, - "parent": Object { - "range": Array [ - 21, - 34, - ], - "type": "VariableDeclaration", + "variableMap": Object { + "arguments": Object { + "$ref": 2, + }, + "test": Object { + "$ref": 3, + }, }, - "type": "Variable", - }, - ], - "eslintUsed": true, - "identifiers": Array [ - Object { - "name": "C", - "range": Array [ - 25, - 34, + "variableScope": Object { + "$ref": 5, + }, + "variables": Array [ + Object { + "$id": 2, + "defs": Array [], + "eslintUsed": undefined, + "identifiers": Array [], + "name": "arguments", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, + Object { + "$id": 3, + "defs": Array [ + Object { + "name": Object { + "name": "test", + "range": Array [ + 49, + 53, + ], + "type": "Identifier", + }, + "node": Object { + "range": Array [ + 40, + 67, + ], + "type": "FunctionExpression", + }, + "parent": null, + "type": "Parameter", + }, + ], + "eslintUsed": undefined, + "identifiers": Array [ + Object { + "name": "test", + "range": Array [ + 49, + 53, + ], + "type": "Identifier", + }, + ], + "name": "test", + "references": Array [], + "scope": Object { + "$ref": 5, + }, + }, ], - "type": "Identifier", - }, - ], - "name": "C", - "references": Array [ - Object { - "$ref": 1, }, ], - "scope": Object { - "$ref": 2, - }, - }, - ], -} -`; - -exports[`TypeScript scope analysis sourceType: script tests/fixtures/scope-analysis/declare-module.ts 1`] = ` -Object { - "$id": 7, - "block": Object { - "range": Array [ - 0, - 95, - ], - "type": "Program", - }, - "childScopes": Array [ - Object { - "$id": 6, - "block": Object { - "range": Array [ - 33, - 92, - ], - "type": "TSModuleBlock", - }, - "childScopes": Array [], "functionExpressionScope": false, - "isStrict": false, - "references": Array [ + "isStrict": true, + "references": Array [], + "throughReferences": Array [ Object { - "$id": 5, - "from": Object { - "$ref": 6, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 89, - 90, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 3, - }, - "writeExpr": undefined, + "$ref": 4, }, ], - "throughReferences": Array [], - "type": "block", + "type": "class", "upperScope": Object { "$ref": 7, }, "variableMap": Object { - "a": Object { - "$ref": 3, - }, - "b": Object { - "$ref": 4, + "Foo": Object { + "$ref": 1, }, }, "variableScope": Object { @@ -13145,96 +15768,40 @@ Object { }, "variables": Array [ Object { - "$id": 3, - "defs": Array [ - Object { - "name": Object { - "name": "a", - "range": Array [ - 52, - 61, - ], - "type": "Identifier", - }, - "node": Object { - "range": Array [ - 52, - 61, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 46, - 61, - ], - "type": "VariableDeclaration", - }, - "type": "Variable", - }, - ], - "eslintUsed": undefined, - "identifiers": Array [ - Object { - "name": "a", - "range": Array [ - 52, - 61, - ], - "type": "Identifier", - }, - ], - "name": "a", - "references": Array [ - Object { - "$ref": 5, - }, - ], - "scope": Object { - "$ref": 6, - }, - }, - Object { - "$id": 4, + "$id": 1, "defs": Array [ Object { "name": Object { - "name": "b", + "name": "Foo", "range": Array [ - 79, - 90, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 79, - 90, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 73, - 90, + 15, + 69, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": undefined, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "b", + "name": "Foo", "range": Array [ - 79, - 90, + 21, + 24, ], "type": "Identifier", }, ], - "name": "b", + "name": "Foo", "references": Array [], "scope": Object { "$ref": 6, @@ -13245,57 +15812,16 @@ Object { ], "functionExpressionScope": false, "isStrict": false, - "references": Array [ - Object { - "$id": 1, - "from": Object { - "$ref": 7, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 6, - 7, - ], - "type": "Identifier", - }, - "kind": "w", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": Object { - "range": Array [ - 10, - 11, - ], - "type": "Literal", - }, - }, + "references": Array [], + "throughReferences": Array [ Object { - "$id": 2, - "from": Object { - "$ref": 7, - }, - "identifier": Object { - "name": "a", - "range": Array [ - 93, - 94, - ], - "type": "Identifier", - }, - "kind": "r", - "resolved": Object { - "$ref": 0, - }, - "writeExpr": undefined, + "$ref": 4, }, ], - "throughReferences": Array [], "type": "global", "upperScope": null, "variableMap": Object { - "a": Object { + "Foo": Object { "$ref": 0, }, }, @@ -13308,50 +15834,37 @@ Object { "defs": Array [ Object { "name": Object { - "name": "a", + "name": "Foo", "range": Array [ - 6, - 7, + 21, + 24, ], "type": "Identifier", }, "node": Object { "range": Array [ - 6, - 11, - ], - "type": "VariableDeclarator", - }, - "parent": Object { - "range": Array [ - 0, - 11, + 15, + 69, ], - "type": "VariableDeclaration", + "type": "ClassDeclaration", }, - "type": "Variable", + "parent": null, + "type": "ClassName", }, ], "eslintUsed": undefined, "identifiers": Array [ Object { - "name": "a", + "name": "Foo", "range": Array [ - 6, - 7, + 21, + 24, ], "type": "Identifier", }, ], - "name": "a", - "references": Array [ - Object { - "$ref": 1, - }, - Object { - "$ref": 2, - }, - ], + "name": "Foo", + "references": Array [], "scope": Object { "$ref": 7, }, diff --git a/packages/parser/typings/eslint-scope.d.ts b/packages/parser/typings/eslint-scope.d.ts index 4822d9a59cca..b6e38be3b160 100644 --- a/packages/parser/typings/eslint-scope.d.ts +++ b/packages/parser/typings/eslint-scope.d.ts @@ -9,7 +9,14 @@ declare module 'eslint-scope/lib/options' { import { TSESTree } from '@typescript-eslint/typescript-estree'; - export type PatternVisitorCallback = (pattern: any, info: any) => void; + export type PatternVisitorCallback = ( + pattern: TSESTree.Node, + info: { + rest: boolean; + topLevel: boolean; + assignments: TSESTree.AssignmentPattern[]; + } + ) => void; export interface PatternVisitorOptions { processRightHandNodes?: boolean; @@ -46,6 +53,7 @@ declare module 'eslint-scope/lib/definition' { parent?: TSESTree.Node | null; index?: number | null; kind?: string | null; + rest?: boolean; constructor( type: string, @@ -58,10 +66,8 @@ declare module 'eslint-scope/lib/definition' { } export class ParameterDefinition extends Definition { - rest?: boolean; - constructor( - name: TSESTree.BindingName | TSESTree.PropertyName, + name: TSESTree.Node, node: TSESTree.Node, index?: number | null, rest?: boolean