Skip to content

Commit d713c58

Browse files
author
Andy Hanson
committed
Fix 8532: Correct source map output for computed getter of object literal
1 parent d8d5daf commit d713c58

25 files changed

+345
-48
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19531953
write("Object.defineProperty(");
19541954
emit(tempVar);
19551955
write(", ");
1956-
emitStart(node.name);
1956+
emitStart(property.name);
19571957
emitExpressionForPropertyName(property.name);
19581958
emitEnd(property.name);
19591959
write(", {");

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.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.

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.sourcemap.txt

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ sourceFile:computedPropertyNamesSourceMap1_ES5.ts
2828
> ["hello"]() {
2929
> debugger;
3030
> }
31+
> get ["goodbye"]() {
32+
> return 0;
33+
> }
3134
>
3235
2 > }
33-
1->Emitted(3, 5) Source(5, 1) + SourceIndex(0)
34-
2 >Emitted(3, 6) Source(5, 2) + SourceIndex(0)
36+
1->Emitted(3, 5) Source(8, 1) + SourceIndex(0)
37+
2 >Emitted(3, 6) Source(8, 2) + SourceIndex(0)
3538
---
3639
>>> C.prototype["hello"] = function () {
3740
1->^^^^
@@ -65,21 +68,78 @@ sourceFile:computedPropertyNamesSourceMap1_ES5.ts
6568
>>> };
6669
1 >^^^^
6770
2 > ^
68-
3 > ^^^^^^^^^->
71+
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
6972
1 >
7073
>
7174
2 > }
7275
1 >Emitted(6, 5) Source(4, 5) + SourceIndex(0)
7376
2 >Emitted(6, 6) Source(4, 6) + SourceIndex(0)
7477
---
78+
>>> Object.defineProperty(C.prototype, "goodbye", {
79+
1->^^^^
80+
2 > ^^^^^^^^^^^^^^^^^^^^^^
81+
3 > ^^^^^^^^^^^^^
82+
4 > ^^^^^^^^^
83+
1->
84+
>
85+
2 > get
86+
3 > [
87+
4 > "goodbye"]
88+
1->Emitted(7, 5) Source(5, 5) + SourceIndex(0)
89+
2 >Emitted(7, 27) Source(5, 9) + SourceIndex(0)
90+
3 >Emitted(7, 40) Source(5, 10) + SourceIndex(0)
91+
4 >Emitted(7, 49) Source(5, 20) + SourceIndex(0)
92+
---
93+
>>> get: function () {
94+
1 >^^^^^^^^^^^^^
95+
2 > ^^^^^^^^^->
96+
1 >
97+
1 >Emitted(8, 14) Source(5, 5) + SourceIndex(0)
98+
---
99+
>>> return 0;
100+
1->^^^^^^^^^^^^
101+
2 > ^^^^^^
102+
3 > ^
103+
4 > ^
104+
5 > ^
105+
1->get ["goodbye"]() {
106+
>
107+
2 > return
108+
3 >
109+
4 > 0
110+
5 > ;
111+
1->Emitted(9, 13) Source(6, 3) + SourceIndex(0)
112+
2 >Emitted(9, 19) Source(6, 9) + SourceIndex(0)
113+
3 >Emitted(9, 20) Source(6, 10) + SourceIndex(0)
114+
4 >Emitted(9, 21) Source(6, 11) + SourceIndex(0)
115+
5 >Emitted(9, 22) Source(6, 12) + SourceIndex(0)
116+
---
117+
>>> },
118+
1 >^^^^^^^^
119+
2 > ^
120+
3 > ^^^^^^^^^^^^^^^^^->
121+
1 >
122+
>
123+
2 > }
124+
1 >Emitted(10, 9) Source(7, 5) + SourceIndex(0)
125+
2 >Emitted(10, 10) Source(7, 6) + SourceIndex(0)
126+
---
127+
>>> enumerable: true,
128+
>>> configurable: true
129+
>>> });
130+
1->^^^^^^^
131+
2 > ^^^^^^^->
132+
1->
133+
1->Emitted(13, 8) Source(7, 6) + SourceIndex(0)
134+
---
75135
>>> return C;
76136
1->^^^^
77137
2 > ^^^^^^^^
78138
1->
79139
>
80140
2 > }
81-
1->Emitted(7, 5) Source(5, 1) + SourceIndex(0)
82-
2 >Emitted(7, 13) Source(5, 2) + SourceIndex(0)
141+
1->Emitted(14, 5) Source(8, 1) + SourceIndex(0)
142+
2 >Emitted(14, 13) Source(8, 2) + SourceIndex(0)
83143
---
84144
>>>}());
85145
1 >
@@ -94,10 +154,13 @@ sourceFile:computedPropertyNamesSourceMap1_ES5.ts
94154
> ["hello"]() {
95155
> debugger;
96156
> }
157+
> get ["goodbye"]() {
158+
> return 0;
159+
> }
97160
> }
98-
1 >Emitted(8, 1) Source(5, 1) + SourceIndex(0)
99-
2 >Emitted(8, 2) Source(5, 2) + SourceIndex(0)
100-
3 >Emitted(8, 2) Source(1, 1) + SourceIndex(0)
101-
4 >Emitted(8, 6) Source(5, 2) + SourceIndex(0)
161+
1 >Emitted(15, 1) Source(8, 1) + SourceIndex(0)
162+
2 >Emitted(15, 2) Source(8, 2) + SourceIndex(0)
163+
3 >Emitted(15, 2) Source(1, 1) + SourceIndex(0)
164+
4 >Emitted(15, 6) Source(8, 2) + SourceIndex(0)
102165
---
103166
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES5.js.map

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ class C {
77

88
debugger;
99
}
10+
get ["goodbye"]() {
11+
>"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5))
12+
13+
return 0;
14+
}
1015
}

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.types

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ class C {
77

88
debugger;
99
}
10+
get ["goodbye"]() {
11+
>"goodbye" : string
12+
13+
return 0;
14+
>0 : number
15+
}
1016
}

tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js

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

tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.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.

tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,57 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts
4545
>>> }
4646
1 >^^^^
4747
2 > ^
48+
3 > ^^^^^^^^^^^^^^^^^^^->
4849
1 >
49-
>
50+
>
51+
2 > }
52+
1 >Emitted(4, 5) Source(4, 2) + SourceIndex(0)
53+
2 >Emitted(4, 6) Source(4, 3) + SourceIndex(0)
54+
---
55+
>>> get ["goodbye"]() {
56+
1->^^^^
57+
2 > ^^^^
58+
3 > ^
59+
4 > ^^^^^^^^^
60+
5 > ^
61+
1->
62+
>
63+
2 > get
64+
3 > [
65+
4 > "goodbye"
66+
5 > ]
67+
1->Emitted(5, 5) Source(5, 2) + SourceIndex(0)
68+
2 >Emitted(5, 9) Source(5, 6) + SourceIndex(0)
69+
3 >Emitted(5, 10) Source(5, 7) + SourceIndex(0)
70+
4 >Emitted(5, 19) Source(5, 16) + SourceIndex(0)
71+
5 >Emitted(5, 20) Source(5, 17) + SourceIndex(0)
72+
---
73+
>>> return 0;
74+
1 >^^^^^^^^
75+
2 > ^^^^^^
76+
3 > ^
77+
4 > ^
78+
5 > ^
79+
1 >() {
80+
>
81+
2 > return
82+
3 >
83+
4 > 0
84+
5 > ;
85+
1 >Emitted(6, 9) Source(6, 3) + SourceIndex(0)
86+
2 >Emitted(6, 15) Source(6, 9) + SourceIndex(0)
87+
3 >Emitted(6, 16) Source(6, 10) + SourceIndex(0)
88+
4 >Emitted(6, 17) Source(6, 11) + SourceIndex(0)
89+
5 >Emitted(6, 18) Source(6, 12) + SourceIndex(0)
90+
---
91+
>>> }
92+
1 >^^^^
93+
2 > ^
94+
1 >
95+
>
5096
2 > }
51-
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0)
52-
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0)
97+
1 >Emitted(7, 5) Source(7, 2) + SourceIndex(0)
98+
2 >Emitted(7, 6) Source(7, 3) + SourceIndex(0)
5399
---
54100
>>>}
55101
1 >
@@ -58,11 +104,11 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts
58104
1 >
59105
>
60106
2 >}
61-
1 >Emitted(5, 1) Source(5, 1) + SourceIndex(0)
62-
2 >Emitted(5, 2) Source(5, 2) + SourceIndex(0)
107+
1 >Emitted(8, 1) Source(8, 1) + SourceIndex(0)
108+
2 >Emitted(8, 2) Source(8, 2) + SourceIndex(0)
63109
---
64110
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1->
65-
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
111+
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
66112
1->
67-
1->Emitted(6, 1) Source(5, 2) + SourceIndex(0)
113+
1->Emitted(9, 1) Source(8, 2) + SourceIndex(0)
68114
---

tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ class C {
66
>"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9))
77

88
debugger;
9-
}
9+
}
10+
get ["goodbye"]() {
11+
>"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 3, 2))
12+
13+
return 0;
14+
}
1015
}

0 commit comments

Comments
 (0)