Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Fix: Allow to visit typeParameters in VariableDeclarator #581

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/fixtures/scope-analysis/type-generic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type foo<A> = Foo<A>
25 changes: 25 additions & 0 deletions tests/lib/__snapshots__/scope-analysis.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions visitor-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down