diff --git a/tests/fixtures/scope-analysis/type-generic.ts b/tests/fixtures/scope-analysis/type-generic.ts new file mode 100644 index 0000000..b26722a --- /dev/null +++ b/tests/fixtures/scope-analysis/type-generic.ts @@ -0,0 +1 @@ +type foo = Foo diff --git a/tests/lib/__snapshots__/scope-analysis.js.snap b/tests/lib/__snapshots__/scope-analysis.js.snap index 6316b14..35a5ec2 100644 --- a/tests/lib/__snapshots__/scope-analysis.js.snap +++ b/tests/lib/__snapshots__/scope-analysis.js.snap @@ -5690,6 +5690,31 @@ Object { } `; +exports[`TypeScript scope analysis tests/fixtures/scope-analysis/type-generic.ts 1`] = ` +Object { + "$id": 0, + "block": Object { + "range": Array [ + 0, + 21, + ], + "type": "Program", + }, + "childScopes": Array [], + "functionExpressionScope": false, + "isStrict": false, + "references": Array [], + "throughReferences": Array [], + "type": "global", + "upperScope": null, + "variableMap": Object {}, + "variableScope": Object { + "$ref": 0, + }, + "variables": Array [], +} +`; + exports[`TypeScript scope analysis tests/fixtures/scope-analysis/typeof.ts 1`] = ` Object { "$id": 3, diff --git a/visitor-keys.js b/visitor-keys.js index 40a5e49..8bc199d 100644 --- a/visitor-keys.js +++ b/visitor-keys.js @@ -21,6 +21,8 @@ module.exports = Evk.unionWith({ ObjectPattern: ["properties", "typeAnnotation"], NewExpression: ["callee", "typeParameters", "arguments"], CallExpression: ["callee", "typeParameters", "arguments"], + // typeParameters are present only when kind='type' + VariableDeclarator: ["id", "typeParameters", "init"], // Additional Nodes. ClassProperty: ["decorators", "key", "typeAnnotation", "value"],