Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 3aae657

Browse filesBrowse files
committed
Fix: missing visitor-keys
- typeParameters in TSInterfaceDeclaration - decorators in Identifier - parameters in TSFunctionType
1 parent 9ed21cb commit 3aae657
Copy full SHA for 3aae657

File tree

Expand file treeCollapse file tree

5 files changed

+291
-3
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+291
-3
lines changed

‎analyze-scope.js

Copy file name to clipboardExpand all lines: analyze-scope.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,12 @@ class Referencer extends OriginalReferencer {
216216
* @returns {void}
217217
*/
218218
Identifier(node) {
219+
this.visitDecorators(node.decorators);
220+
219221
if (!this.typeMode) {
220222
super.Identifier(node);
221223
}
224+
222225
this.visit(node.typeAnnotation);
223226
}
224227

+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export class Test {
2+
constructor(@Decorator config) {
3+
}
4+
}
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface C<T = any> {
2+
3+
}
4+
5+
interface R<T extends C> {
6+
foo: C
7+
}

‎tests/lib/__snapshots__/scope-analysis.js.snap

Copy file name to clipboardExpand all lines: tests/lib/__snapshots__/scope-analysis.js.snap
+274Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,6 +2927,255 @@ Object {
29272927
}
29282928
`;
29292929

2930+
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/identifier-decorators.ts 1`] = `
2931+
Object {
2932+
"$id": 7,
2933+
"block": Object {
2934+
"range": Array [
2935+
0,
2936+
65,
2937+
],
2938+
"type": "Program",
2939+
},
2940+
"childScopes": Array [
2941+
Object {
2942+
"$id": 6,
2943+
"block": Object {
2944+
"range": Array [
2945+
0,
2946+
65,
2947+
],
2948+
"type": "Program",
2949+
},
2950+
"childScopes": Array [
2951+
Object {
2952+
"$id": 5,
2953+
"block": Object {
2954+
"range": Array [
2955+
7,
2956+
64,
2957+
],
2958+
"type": "ClassDeclaration",
2959+
},
2960+
"childScopes": Array [
2961+
Object {
2962+
"$id": 4,
2963+
"block": Object {
2964+
"range": Array [
2965+
35,
2966+
62,
2967+
],
2968+
"type": "FunctionExpression",
2969+
},
2970+
"childScopes": Array [],
2971+
"functionExpressionScope": false,
2972+
"isStrict": true,
2973+
"references": Array [],
2974+
"throughReferences": Array [],
2975+
"type": "function",
2976+
"upperScope": Object {
2977+
"$ref": 5,
2978+
},
2979+
"variableMap": Object {
2980+
"arguments": Object {
2981+
"$ref": 2,
2982+
},
2983+
"config": Object {
2984+
"$ref": 3,
2985+
},
2986+
},
2987+
"variableScope": Object {
2988+
"$ref": 4,
2989+
},
2990+
"variables": Array [
2991+
Object {
2992+
"$id": 2,
2993+
"defs": Array [],
2994+
"eslintUsed": undefined,
2995+
"identifiers": Array [],
2996+
"name": "arguments",
2997+
"references": Array [],
2998+
"scope": Object {
2999+
"$ref": 4,
3000+
},
3001+
},
3002+
Object {
3003+
"$id": 3,
3004+
"defs": Array [
3005+
Object {
3006+
"name": Object {
3007+
"name": "config",
3008+
"range": Array [
3009+
47,
3010+
53,
3011+
],
3012+
"type": "Identifier",
3013+
},
3014+
"node": Object {
3015+
"range": Array [
3016+
35,
3017+
62,
3018+
],
3019+
"type": "FunctionExpression",
3020+
},
3021+
"parent": null,
3022+
"type": "Parameter",
3023+
},
3024+
],
3025+
"eslintUsed": undefined,
3026+
"identifiers": Array [
3027+
Object {
3028+
"name": "config",
3029+
"range": Array [
3030+
47,
3031+
53,
3032+
],
3033+
"type": "Identifier",
3034+
},
3035+
],
3036+
"name": "config",
3037+
"references": Array [],
3038+
"scope": Object {
3039+
"$ref": 4,
3040+
},
3041+
},
3042+
],
3043+
},
3044+
],
3045+
"functionExpressionScope": false,
3046+
"isStrict": true,
3047+
"references": Array [],
3048+
"throughReferences": Array [],
3049+
"type": "class",
3050+
"upperScope": Object {
3051+
"$ref": 6,
3052+
},
3053+
"variableMap": Object {
3054+
"Test": Object {
3055+
"$ref": 1,
3056+
},
3057+
},
3058+
"variableScope": Object {
3059+
"$ref": 6,
3060+
},
3061+
"variables": Array [
3062+
Object {
3063+
"$id": 1,
3064+
"defs": Array [
3065+
Object {
3066+
"name": Object {
3067+
"name": "Test",
3068+
"range": Array [
3069+
13,
3070+
17,
3071+
],
3072+
"type": "Identifier",
3073+
},
3074+
"node": Object {
3075+
"range": Array [
3076+
7,
3077+
64,
3078+
],
3079+
"type": "ClassDeclaration",
3080+
},
3081+
"parent": undefined,
3082+
"type": "ClassName",
3083+
},
3084+
],
3085+
"eslintUsed": undefined,
3086+
"identifiers": Array [
3087+
Object {
3088+
"name": "Test",
3089+
"range": Array [
3090+
13,
3091+
17,
3092+
],
3093+
"type": "Identifier",
3094+
},
3095+
],
3096+
"name": "Test",
3097+
"references": Array [],
3098+
"scope": Object {
3099+
"$ref": 5,
3100+
},
3101+
},
3102+
],
3103+
},
3104+
],
3105+
"functionExpressionScope": false,
3106+
"isStrict": true,
3107+
"references": Array [],
3108+
"throughReferences": Array [],
3109+
"type": "module",
3110+
"upperScope": Object {
3111+
"$ref": 7,
3112+
},
3113+
"variableMap": Object {
3114+
"Test": Object {
3115+
"$ref": 0,
3116+
},
3117+
},
3118+
"variableScope": Object {
3119+
"$ref": 6,
3120+
},
3121+
"variables": Array [
3122+
Object {
3123+
"$id": 0,
3124+
"defs": Array [
3125+
Object {
3126+
"name": Object {
3127+
"name": "Test",
3128+
"range": Array [
3129+
13,
3130+
17,
3131+
],
3132+
"type": "Identifier",
3133+
},
3134+
"node": Object {
3135+
"range": Array [
3136+
7,
3137+
64,
3138+
],
3139+
"type": "ClassDeclaration",
3140+
},
3141+
"parent": null,
3142+
"type": "ClassName",
3143+
},
3144+
],
3145+
"eslintUsed": undefined,
3146+
"identifiers": Array [
3147+
Object {
3148+
"name": "Test",
3149+
"range": Array [
3150+
13,
3151+
17,
3152+
],
3153+
"type": "Identifier",
3154+
},
3155+
],
3156+
"name": "Test",
3157+
"references": Array [],
3158+
"scope": Object {
3159+
"$ref": 6,
3160+
},
3161+
},
3162+
],
3163+
},
3164+
],
3165+
"functionExpressionScope": false,
3166+
"isStrict": false,
3167+
"references": Array [],
3168+
"throughReferences": Array [],
3169+
"type": "global",
3170+
"upperScope": null,
3171+
"variableMap": Object {},
3172+
"variableScope": Object {
3173+
"$ref": 7,
3174+
},
3175+
"variables": Array [],
3176+
}
3177+
`;
3178+
29303179
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/ignore-type-only-stuff.ts 1`] = `
29313180
Object {
29323181
"$id": 1,
@@ -3003,6 +3252,31 @@ Object {
30033252
}
30043253
`;
30053254

3255+
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/interface-type.ts 1`] = `
3256+
Object {
3257+
"$id": 0,
3258+
"block": Object {
3259+
"range": Array [
3260+
0,
3261+
67,
3262+
],
3263+
"type": "Program",
3264+
},
3265+
"childScopes": Array [],
3266+
"functionExpressionScope": false,
3267+
"isStrict": false,
3268+
"references": Array [],
3269+
"throughReferences": Array [],
3270+
"type": "global",
3271+
"upperScope": null,
3272+
"variableMap": Object {},
3273+
"variableScope": Object {
3274+
"$ref": 0,
3275+
},
3276+
"variables": Array [],
3277+
}
3278+
`;
3279+
30063280
exports[`TypeScript scope analysis tests/fixtures/scope-analysis/method-overload.ts 1`] = `
30073281
Object {
30083282
"$id": 10,

‎visitor-keys.js

Copy file name to clipboardExpand all lines: visitor-keys.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = Evk.unionWith({
1616
ClassExpression: ["decorators", "id", "typeParameters", "superClass", "body"],
1717
FunctionDeclaration: ["id", "typeParameters", "params", "returnType", "body"],
1818
FunctionExpression: ["id", "typeParameters", "params", "returnType", "body"],
19-
Identifier: ["typeAnnotation"],
19+
Identifier: ["decorators", "typeAnnotation"],
2020
MethodDefinition: ["decorators", "key", "value"],
2121
ObjectPattern: ["properties", "typeAnnotation"],
2222

@@ -46,9 +46,9 @@ module.exports = Evk.unionWith({
4646
TSLiteralType: ["literal"],
4747
TSIndexSignature: ["typeAnnotation", "index"],
4848
TSInterfaceBody: ["body"],
49-
TSInterfaceDeclaration: ["body", "id", "heritage"],
49+
TSInterfaceDeclaration: ["body", "id", "heritage", "typeParameters"],
5050
TSInterfaceHeritage: ["id", "typeParameters"],
51-
TSFunctionType: ["typeAnnotation"],
51+
TSFunctionType: ["parameters", "typeAnnotation"],
5252
TSMethodSignature: ["typeAnnotation", "typeParameters", "key", "params"],
5353
TSModuleBlock: ["body"],
5454
TSModuleDeclaration: ["id", "body"],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.