Skip to content

Commit ba2238f

Browse files
committed
Decorators node array should have pos at token @ instead of actual decorator expression
1 parent 83e569e commit ba2238f

4 files changed

Lines changed: 71 additions & 162 deletions

File tree

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4890,7 +4890,7 @@ namespace ts {
48904890

48914891
if (!decorators) {
48924892
decorators = <NodeArray<Decorator>>[];
4893-
decorators.pos = scanner.getStartPos();
4893+
decorators.pos = decoratorStart;
48944894
}
48954895

48964896
const decorator = <Decorator>createNode(SyntaxKind.Decorator, decoratorStart);

tests/baselines/reference/bpSpan_decorators.baseline

Lines changed: 54 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -29,66 +29,17 @@
2929
--------------------------------
3030
8 >@ClassDecorator1
3131

32-
~ => Pos: (594 to 594) SpanInfo: {"start":632,"length":914}
33-
>class Greeter {
34-
> constructor(
35-
> @ParameterDecorator1
36-
> @ParameterDecorator2(20)
37-
> public greeting: string,
38-
>
39-
> @ParameterDecorator1
40-
> @ParameterDecorator2(30)
41-
> ...b: string[]) {
42-
> }
43-
>
44-
> @PropertyDecorator1
45-
> @PropertyDecorator2(40)
46-
> greet() {
47-
> return "<h1>" + this.greeting + "</h1>";
48-
> }
49-
>
50-
> @PropertyDecorator1
51-
> @PropertyDecorator2(50)
52-
> private x: string;
53-
>
54-
> @PropertyDecorator1
55-
> @PropertyDecorator2(60)
56-
> private static x1: number = 10;
57-
>
58-
> private fn(
59-
> @ParameterDecorator1
60-
> @ParameterDecorator2(70)
61-
> x: number) {
62-
> return this.greeting;
63-
> }
64-
>
65-
> @PropertyDecorator1
66-
> @PropertyDecorator2(80)
67-
> get greetings() {
68-
> return this.greeting;
69-
> }
70-
>
71-
> set greetings(
72-
> @ParameterDecorator1
73-
> @ParameterDecorator2(90)
74-
> greetings: string) {
75-
> this.greeting = greetings;
76-
> }
77-
>}
78-
>:=> (line 10, col 0) to (line 54, col 1)
79-
8 >@ClassDecorator1
80-
81-
~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36}
82-
>ClassDecorator1
32+
~~~~~~~~~~~~~~~~~ => Pos: (594 to 610) SpanInfo: {"start":594,"length":37}
33+
>@ClassDecorator1
8334
>@ClassDecorator2(10)
84-
>:=> (line 8, col 1) to (line 9, col 20)
35+
>:=> (line 8, col 0) to (line 9, col 20)
8536
--------------------------------
8637
9 >@ClassDecorator2(10)
8738

88-
~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":595,"length":36}
89-
>ClassDecorator1
39+
~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":594,"length":37}
40+
>@ClassDecorator1
9041
>@ClassDecorator2(10)
91-
>:=> (line 8, col 1) to (line 9, col 20)
42+
>:=> (line 8, col 0) to (line 9, col 20)
9243
--------------------------------
9344
10 >class Greeter {
9445

@@ -148,22 +99,17 @@
14899
--------------------------------
149100
12 > @ParameterDecorator1
150101

151-
~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":735,"length":23}
152-
>public greeting: string
153-
>:=> (line 14, col 8) to (line 14, col 31)
154-
12 > @ParameterDecorator1
155-
156-
~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52}
157-
>ParameterDecorator1
102+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (665 to 693) SpanInfo: {"start":673,"length":53}
103+
>@ParameterDecorator1
158104
> @ParameterDecorator2(20)
159-
>:=> (line 12, col 9) to (line 13, col 32)
105+
>:=> (line 12, col 8) to (line 13, col 32)
160106
--------------------------------
161107
13 > @ParameterDecorator2(20)
162108

163-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":674,"length":52}
164-
>ParameterDecorator1
109+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":673,"length":53}
110+
>@ParameterDecorator1
165111
> @ParameterDecorator2(20)
166-
>:=> (line 12, col 9) to (line 13, col 32)
112+
>:=> (line 12, col 8) to (line 13, col 32)
167113
--------------------------------
168114
14 > public greeting: string,
169115

@@ -177,22 +123,17 @@
177123
--------------------------------
178124
16 > @ParameterDecorator1
179125

180-
~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":835,"length":14}
181-
>...b: string[]
182-
>:=> (line 18, col 12) to (line 18, col 26)
183-
16 > @ParameterDecorator1
184-
185-
~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52}
186-
>ParameterDecorator1
126+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (761 to 789) SpanInfo: {"start":769,"length":53}
127+
>@ParameterDecorator1
187128
> @ParameterDecorator2(30)
188-
>:=> (line 16, col 9) to (line 17, col 32)
129+
>:=> (line 16, col 8) to (line 17, col 32)
189130
--------------------------------
190131
17 > @ParameterDecorator2(30)
191132

192-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":770,"length":52}
193-
>ParameterDecorator1
133+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":769,"length":53}
134+
>@ParameterDecorator1
194135
> @ParameterDecorator2(30)
195-
>:=> (line 16, col 9) to (line 17, col 32)
136+
>:=> (line 16, col 8) to (line 17, col 32)
196137
--------------------------------
197138
18 > ...b: string[]) {
198139

@@ -217,24 +158,17 @@
217158
--------------------------------
218159
21 > @PropertyDecorator1
219160

220-
~~~~~ => Pos: (860 to 864) SpanInfo: {"start":916,"length":64}
221-
>greet() {
222-
> return "<h1>" + this.greeting + "</h1>";
223-
> }
224-
>:=> (line 23, col 4) to (line 25, col 5)
225-
21 > @PropertyDecorator1
226-
227-
~~~~~~~~~~~~~~~~~~~ => Pos: (865 to 883) SpanInfo: {"start":865,"length":46}
228-
>PropertyDecorator1
161+
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (860 to 883) SpanInfo: {"start":864,"length":47}
162+
>@PropertyDecorator1
229163
> @PropertyDecorator2(40)
230-
>:=> (line 21, col 5) to (line 22, col 27)
164+
>:=> (line 21, col 4) to (line 22, col 27)
231165
--------------------------------
232166
22 > @PropertyDecorator2(40)
233167

234-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":865,"length":46}
235-
>PropertyDecorator1
168+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":864,"length":47}
169+
>@PropertyDecorator1
236170
> @PropertyDecorator2(40)
237-
>:=> (line 21, col 5) to (line 22, col 27)
171+
>:=> (line 21, col 4) to (line 22, col 27)
238172
--------------------------------
239173
23 > greet() {
240174

@@ -267,20 +201,17 @@
267201
--------------------------------
268202
27 > @PropertyDecorator1
269203

270-
~~~~~ => Pos: (982 to 986) SpanInfo: undefined
271-
27 > @PropertyDecorator1
272-
273-
~~~~~~~~~~~~~~~~~~~ => Pos: (987 to 1005) SpanInfo: {"start":987,"length":46}
274-
>PropertyDecorator1
204+
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (982 to 1005) SpanInfo: {"start":986,"length":47}
205+
>@PropertyDecorator1
275206
> @PropertyDecorator2(50)
276-
>:=> (line 27, col 5) to (line 28, col 27)
207+
>:=> (line 27, col 4) to (line 28, col 27)
277208
--------------------------------
278209
28 > @PropertyDecorator2(50)
279210

280-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":987,"length":46}
281-
>PropertyDecorator1
211+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":986,"length":47}
212+
>@PropertyDecorator1
282213
> @PropertyDecorator2(50)
283-
>:=> (line 27, col 5) to (line 28, col 27)
214+
>:=> (line 27, col 4) to (line 28, col 27)
284215
--------------------------------
285216
29 > private x: string;
286217

@@ -292,22 +223,17 @@
292223
--------------------------------
293224
31 > @PropertyDecorator1
294225

295-
~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1114,"length":31}
296-
>private static x1: number = 10;
297-
>:=> (line 33, col 4) to (line 33, col 35)
298-
31 > @PropertyDecorator1
299-
300-
~~~~~~~~~~~~~~~~~~~ => Pos: (1063 to 1081) SpanInfo: {"start":1063,"length":46}
301-
>PropertyDecorator1
226+
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1058 to 1081) SpanInfo: {"start":1062,"length":47}
227+
>@PropertyDecorator1
302228
> @PropertyDecorator2(60)
303-
>:=> (line 31, col 5) to (line 32, col 27)
229+
>:=> (line 31, col 4) to (line 32, col 27)
304230
--------------------------------
305231
32 > @PropertyDecorator2(60)
306232

307-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1063,"length":46}
308-
>PropertyDecorator1
233+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1062,"length":47}
234+
>@PropertyDecorator1
309235
> @PropertyDecorator2(60)
310-
>:=> (line 31, col 5) to (line 32, col 27)
236+
>:=> (line 31, col 4) to (line 32, col 27)
311237
--------------------------------
312238
33 > private static x1: number = 10;
313239

@@ -332,22 +258,17 @@
332258
--------------------------------
333259
36 > @ParameterDecorator1
334260

335-
~~~~~~~~~ => Pos: (1163 to 1171) SpanInfo: {"start":1254,"length":20}
336-
>return this.greeting
337-
>:=> (line 39, col 8) to (line 39, col 28)
338-
36 > @ParameterDecorator1
339-
340-
~~~~~~~~~~~~~~~~~~~~ => Pos: (1172 to 1191) SpanInfo: {"start":1172,"length":52}
341-
>ParameterDecorator1
261+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1163 to 1191) SpanInfo: {"start":1171,"length":53}
262+
>@ParameterDecorator1
342263
> @ParameterDecorator2(70)
343-
>:=> (line 36, col 9) to (line 37, col 32)
264+
>:=> (line 36, col 8) to (line 37, col 32)
344265
--------------------------------
345266
37 > @ParameterDecorator2(70)
346267

347-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1172,"length":52}
348-
>ParameterDecorator1
268+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1171,"length":53}
269+
>@ParameterDecorator1
349270
> @ParameterDecorator2(70)
350-
>:=> (line 36, col 9) to (line 37, col 32)
271+
>:=> (line 36, col 8) to (line 37, col 32)
351272
--------------------------------
352273
38 > x: number) {
353274

@@ -373,24 +294,17 @@
373294
--------------------------------
374295
42 > @PropertyDecorator1
375296

376-
~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1339,"length":53}
377-
>get greetings() {
378-
> return this.greeting;
379-
> }
380-
>:=> (line 44, col 4) to (line 46, col 5)
381-
42 > @PropertyDecorator1
382-
383-
~~~~~~~~~~~~~~~~~~~ => Pos: (1288 to 1306) SpanInfo: {"start":1288,"length":46}
384-
>PropertyDecorator1
297+
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1283 to 1306) SpanInfo: {"start":1287,"length":47}
298+
>@PropertyDecorator1
385299
> @PropertyDecorator2(80)
386-
>:=> (line 42, col 5) to (line 43, col 27)
300+
>:=> (line 42, col 4) to (line 43, col 27)
387301
--------------------------------
388302
43 > @PropertyDecorator2(80)
389303

390-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1288,"length":46}
391-
>PropertyDecorator1
304+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1287,"length":47}
305+
>@PropertyDecorator1
392306
> @PropertyDecorator2(80)
393-
>:=> (line 42, col 5) to (line 43, col 27)
307+
>:=> (line 42, col 4) to (line 43, col 27)
394308
--------------------------------
395309
44 > get greetings() {
396310

@@ -434,22 +348,17 @@
434348
--------------------------------
435349
49 > @ParameterDecorator1
436350

437-
~~~~~~~~~ => Pos: (1413 to 1421) SpanInfo: {"start":1512,"length":25}
438-
>this.greeting = greetings
439-
>:=> (line 52, col 8) to (line 52, col 33)
440-
49 > @ParameterDecorator1
441-
442-
~~~~~~~~~~~~~~~~~~~~ => Pos: (1422 to 1441) SpanInfo: {"start":1422,"length":52}
443-
>ParameterDecorator1
351+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1413 to 1441) SpanInfo: {"start":1421,"length":53}
352+
>@ParameterDecorator1
444353
> @ParameterDecorator2(90)
445-
>:=> (line 49, col 9) to (line 50, col 32)
354+
>:=> (line 49, col 8) to (line 50, col 32)
446355
--------------------------------
447356
50 > @ParameterDecorator2(90)
448357

449-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1422,"length":52}
450-
>ParameterDecorator1
358+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1421,"length":53}
359+
>@ParameterDecorator1
451360
> @ParameterDecorator2(90)
452-
>:=> (line 49, col 9) to (line 50, col 32)
361+
>:=> (line 49, col 8) to (line 50, col 32)
453362
--------------------------------
454363
51 > greetings: string) {
455364

tests/baselines/reference/sourceMapValidationDecorators.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)