Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14b33a4

Browse files
authored
test: add fixtures for exported classes with decorators (typescript-eslint#5558)
1 parent 96b615a commit 14b33a4

File tree

6 files changed

+561
-0
lines changed

6 files changed

+561
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sealed
2+
export default class Qux {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sealed
2+
export class Qux {}

packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,14 @@ tester.addFixturePatternConfig('typescript/decorators/accessor-decorators', {
437437
});
438438
tester.addFixturePatternConfig('typescript/decorators/class-decorators', {
439439
fileType: 'ts',
440+
ignore: [
441+
/**
442+
* babel sets the range of the export node to the start of the decorator
443+
* TSESTree sets it to the start of the export keyword
444+
*/
445+
'export-default-class-decorator',
446+
'export-named-class-decorator',
447+
],
440448
});
441449
tester.addFixturePatternConfig('typescript/decorators/method-decorators', {
442450
fileType: 'ts',

packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e
22242224

22252225
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/class-decorator-factory.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
22262226

2227+
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/export-default-class-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
2228+
2229+
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/class-decorators/export-named-class-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
2230+
22272231
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/method-decorators/method-decorator-factory-instance-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
22282232

22292233
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/method-decorators/method-decorator-factory-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`typescript decorators class-decorators export-default-class-decorator.src 1`] = `
4+
Object {
5+
"body": Array [
6+
Object {
7+
"declaration": Object {
8+
"body": Object {
9+
"body": Array [],
10+
"loc": Object {
11+
"end": Object {
12+
"column": 27,
13+
"line": 2,
14+
},
15+
"start": Object {
16+
"column": 25,
17+
"line": 2,
18+
},
19+
},
20+
"range": Array [
21+
33,
22+
35,
23+
],
24+
"type": "ClassBody",
25+
},
26+
"decorators": Array [
27+
Object {
28+
"expression": Object {
29+
"loc": Object {
30+
"end": Object {
31+
"column": 7,
32+
"line": 1,
33+
},
34+
"start": Object {
35+
"column": 1,
36+
"line": 1,
37+
},
38+
},
39+
"name": "sealed",
40+
"range": Array [
41+
1,
42+
7,
43+
],
44+
"type": "Identifier",
45+
},
46+
"loc": Object {
47+
"end": Object {
48+
"column": 7,
49+
"line": 1,
50+
},
51+
"start": Object {
52+
"column": 0,
53+
"line": 1,
54+
},
55+
},
56+
"range": Array [
57+
0,
58+
7,
59+
],
60+
"type": "Decorator",
61+
},
62+
],
63+
"id": Object {
64+
"loc": Object {
65+
"end": Object {
66+
"column": 24,
67+
"line": 2,
68+
},
69+
"start": Object {
70+
"column": 21,
71+
"line": 2,
72+
},
73+
},
74+
"name": "Qux",
75+
"range": Array [
76+
29,
77+
32,
78+
],
79+
"type": "Identifier",
80+
},
81+
"loc": Object {
82+
"end": Object {
83+
"column": 27,
84+
"line": 2,
85+
},
86+
"start": Object {
87+
"column": 15,
88+
"line": 2,
89+
},
90+
},
91+
"range": Array [
92+
23,
93+
35,
94+
],
95+
"superClass": null,
96+
"type": "ClassDeclaration",
97+
},
98+
"exportKind": "value",
99+
"loc": Object {
100+
"end": Object {
101+
"column": 27,
102+
"line": 2,
103+
},
104+
"start": Object {
105+
"column": 0,
106+
"line": 2,
107+
},
108+
},
109+
"range": Array [
110+
8,
111+
35,
112+
],
113+
"type": "ExportDefaultDeclaration",
114+
},
115+
],
116+
"comments": Array [],
117+
"loc": Object {
118+
"end": Object {
119+
"column": 0,
120+
"line": 3,
121+
},
122+
"start": Object {
123+
"column": 0,
124+
"line": 1,
125+
},
126+
},
127+
"range": Array [
128+
0,
129+
36,
130+
],
131+
"sourceType": "module",
132+
"tokens": Array [
133+
Object {
134+
"loc": Object {
135+
"end": Object {
136+
"column": 1,
137+
"line": 1,
138+
},
139+
"start": Object {
140+
"column": 0,
141+
"line": 1,
142+
},
143+
},
144+
"range": Array [
145+
0,
146+
1,
147+
],
148+
"type": "Punctuator",
149+
"value": "@",
150+
},
151+
Object {
152+
"loc": Object {
153+
"end": Object {
154+
"column": 7,
155+
"line": 1,
156+
},
157+
"start": Object {
158+
"column": 1,
159+
"line": 1,
160+
},
161+
},
162+
"range": Array [
163+
1,
164+
7,
165+
],
166+
"type": "Identifier",
167+
"value": "sealed",
168+
},
169+
Object {
170+
"loc": Object {
171+
"end": Object {
172+
"column": 6,
173+
"line": 2,
174+
},
175+
"start": Object {
176+
"column": 0,
177+
"line": 2,
178+
},
179+
},
180+
"range": Array [
181+
8,
182+
14,
183+
],
184+
"type": "Keyword",
185+
"value": "export",
186+
},
187+
Object {
188+
"loc": Object {
189+
"end": Object {
190+
"column": 14,
191+
"line": 2,
192+
},
193+
"start": Object {
194+
"column": 7,
195+
"line": 2,
196+
},
197+
},
198+
"range": Array [
199+
15,
200+
22,
201+
],
202+
"type": "Keyword",
203+
"value": "default",
204+
},
205+
Object {
206+
"loc": Object {
207+
"end": Object {
208+
"column": 20,
209+
"line": 2,
210+
},
211+
"start": Object {
212+
"column": 15,
213+
"line": 2,
214+
},
215+
},
216+
"range": Array [
217+
23,
218+
28,
219+
],
220+
"type": "Keyword",
221+
"value": "class",
222+
},
223+
Object {
224+
"loc": Object {
225+
"end": Object {
226+
"column": 24,
227+
"line": 2,
228+
},
229+
"start": Object {
230+
"column": 21,
231+
"line": 2,
232+
},
233+
},
234+
"range": Array [
235+
29,
236+
32,
237+
],
238+
"type": "Identifier",
239+
"value": "Qux",
240+
},
241+
Object {
242+
"loc": Object {
243+
"end": Object {
244+
"column": 26,
245+
"line": 2,
246+
},
247+
"start": Object {
248+
"column": 25,
249+
"line": 2,
250+
},
251+
},
252+
"range": Array [
253+
33,
254+
34,
255+
],
256+
"type": "Punctuator",
257+
"value": "{",
258+
},
259+
Object {
260+
"loc": Object {
261+
"end": Object {
262+
"column": 27,
263+
"line": 2,
264+
},
265+
"start": Object {
266+
"column": 26,
267+
"line": 2,
268+
},
269+
},
270+
"range": Array [
271+
34,
272+
35,
273+
],
274+
"type": "Punctuator",
275+
"value": "}",
276+
},
277+
],
278+
"type": "Program",
279+
}
280+
`;

0 commit comments

Comments
 (0)