File tree Expand file tree Collapse file tree 4 files changed +107
-3
lines changed
eslint-plugin/tests/rules
tests/fixtures/class/declaration Expand file tree Collapse file tree 4 files changed +107
-3
lines changed Original file line number Diff line number Diff line change @@ -757,6 +757,14 @@ export default function (@Optional() value = []) {
757
757
758
758
function Optional() {
759
759
return () => {};
760
+ }
761
+ ` ,
762
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2417
763
+ `
764
+ import { FooType } from './fileA';
765
+
766
+ export abstract class Foo {
767
+ protected abstract readonly type: FooType;
760
768
}
761
769
` ,
762
770
] ,
Original file line number Diff line number Diff line change @@ -139,6 +139,13 @@ class Referencer extends Visitor {
139
139
this . close ( node ) ;
140
140
}
141
141
142
+ protected visitClassProperty (
143
+ node : TSESTree . TSAbstractClassProperty | TSESTree . ClassProperty ,
144
+ ) : void {
145
+ this . visitProperty ( node ) ;
146
+ this . visitType ( node . typeAnnotation ) ;
147
+ }
148
+
142
149
protected visitForIn (
143
150
node : TSESTree . ForInStatement | TSESTree . ForOfStatement ,
144
151
) : void {
@@ -413,8 +420,7 @@ class Referencer extends Visitor {
413
420
}
414
421
415
422
protected ClassProperty ( node : TSESTree . ClassProperty ) : void {
416
- this . visitProperty ( node ) ;
417
- this . visitType ( node . typeAnnotation ) ;
423
+ this . visitClassProperty ( node ) ;
418
424
}
419
425
420
426
protected ContinueStatement ( ) : void {
@@ -562,7 +568,7 @@ class Referencer extends Visitor {
562
568
protected TSAbstractClassProperty (
563
569
node : TSESTree . TSAbstractClassProperty ,
564
570
) : void {
565
- this . visitProperty ( node ) ;
571
+ this . visitClassProperty ( node ) ;
566
572
}
567
573
568
574
protected TSAbstractMethodDefinition (
Original file line number Diff line number Diff line change
1
+ type T = 1 ;
2
+
3
+ abstract class Foo {
4
+ protected abstract readonly prop : T ;
5
+ }
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`class declaration abstract-property 1`] = `
4
+ ScopeManager {
5
+ variables: Array [
6
+ Variable$1 {
7
+ defs: Array [
8
+ TypeDefinition$1 {
9
+ name: Identifier<"T">,
10
+ node: TSTypeAliasDeclaration$1,
11
+ },
12
+ ],
13
+ name: "T",
14
+ references: Array [
15
+ Reference$1 {
16
+ identifier: Identifier<"T">,
17
+ isRead: true,
18
+ isTypeReference: true,
19
+ isValueReference: false,
20
+ isWrite: false,
21
+ resolved: Variable$1,
22
+ },
23
+ ],
24
+ isValueVariable: false,
25
+ isTypeVariable: true,
26
+ },
27
+ Variable$2 {
28
+ defs: Array [
29
+ ClassNameDefinition$2 {
30
+ name: Identifier<"Foo">,
31
+ node: ClassDeclaration$2,
32
+ },
33
+ ],
34
+ name: "Foo",
35
+ references: Array [],
36
+ isValueVariable: true,
37
+ isTypeVariable: true,
38
+ },
39
+ Variable$3 {
40
+ defs: Array [
41
+ ClassNameDefinition$3 {
42
+ name: Identifier<"Foo">,
43
+ node: ClassDeclaration$2,
44
+ },
45
+ ],
46
+ name: "Foo",
47
+ references: Array [],
48
+ isValueVariable: true,
49
+ isTypeVariable: true,
50
+ },
51
+ ],
52
+ scopes: Array [
53
+ GlobalScope$1 {
54
+ block: Program$3,
55
+ isStrict: false,
56
+ references: Array [],
57
+ set: Map {
58
+ "T" => Variable$1,
59
+ "Foo" => Variable$2,
60
+ },
61
+ type: "global",
62
+ upper: null,
63
+ variables: Array [
64
+ Variable$1,
65
+ Variable$2,
66
+ ],
67
+ },
68
+ ClassScope$2 {
69
+ block: ClassDeclaration$2,
70
+ isStrict: true,
71
+ references: Array [
72
+ Reference$1,
73
+ ],
74
+ set: Map {
75
+ "Foo" => Variable$3,
76
+ },
77
+ type: "class",
78
+ upper: GlobalScope$1,
79
+ variables: Array [
80
+ Variable$3,
81
+ ],
82
+ },
83
+ ],
84
+ }
85
+ `;
You can’t perform that action at this time.
0 commit comments