Skip to content

Commit 20ecbb0

Browse files
author
Orta
authored
Allow Source Mapping inside destructuring assignment (#37298)
* Add support for source maps inside of destructured code * Adds tests for the source maps inside destructured code
1 parent 7317292 commit 20ecbb0

File tree

113 files changed

+28039
-14657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+28039
-14657
lines changed

src/compiler/transformers/destructuring.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ namespace ts {
107107
return aggregateTransformFlags(inlineExpressions(expressions!)) || createOmittedExpression();
108108

109109
function emitExpression(expression: Expression) {
110-
// NOTE: this completely disables source maps, but aligns with the behavior of
111-
// `emitAssignment` in the old emitter.
112-
setEmitFlags(expression, EmitFlags.NoNestedSourceMaps);
113110
aggregateTransformFlags(expression);
114111
expressions = append(expressions, expression);
115112
}
@@ -234,9 +231,6 @@ namespace ts {
234231
);
235232
variable.original = original;
236233
setTextRange(variable, location);
237-
if (isIdentifier(name)) {
238-
setEmitFlags(variable, EmitFlags.NoNestedSourceMaps);
239-
}
240234
aggregateTransformFlags(variable);
241235
declarations.push(variable);
242236
}

tests/baselines/reference/ES5For-of26.js.map

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

tests/baselines/reference/ES5For-of26.sourcemap.txt

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,51 @@ sourceFile:ES5For-of26.ts
6060
4 > ^^
6161
5 > ^^^^^^^^^^
6262
6 > ^^
63-
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
64-
8 > ^^
65-
9 > ^^^^^^^^^^
66-
10> ^^
67-
11> ^^^^^^^^^^^^^^^^^^^^^^^^^^
63+
7 > ^
64+
8 > ^^^^^^^^^^^^^^^^^^^
65+
9 > ^
66+
10> ^^^^^
67+
11> ^^
68+
12> ^^^^^^^^^^
69+
13> ^^
70+
14> ^
71+
15> ^^^^^^^^^^^^^^^^^^^
72+
16> ^
73+
17> ^^^^^
6874
1->
6975
2 >
7076
3 > [a = 0, b = 1]
7177
4 >
7278
5 > a = 0
7379
6 >
74-
7 > a = 0
75-
8 > ,
76-
9 > b = 1
77-
10>
78-
11> b = 1
80+
7 > a
81+
8 > =
82+
9 > 0
83+
10>
84+
11> ,
85+
12> b = 1
86+
13>
87+
14> b
88+
15> =
89+
16> 1
90+
17>
7991
1->Emitted(2, 5) Source(1, 10) + SourceIndex(0)
8092
2 >Emitted(2, 9) Source(1, 10) + SourceIndex(0)
8193
3 >Emitted(2, 20) Source(1, 24) + SourceIndex(0)
8294
4 >Emitted(2, 22) Source(1, 11) + SourceIndex(0)
8395
5 >Emitted(2, 32) Source(1, 16) + SourceIndex(0)
8496
6 >Emitted(2, 34) Source(1, 11) + SourceIndex(0)
85-
7 >Emitted(2, 60) Source(1, 16) + SourceIndex(0)
86-
8 >Emitted(2, 62) Source(1, 18) + SourceIndex(0)
87-
9 >Emitted(2, 72) Source(1, 23) + SourceIndex(0)
88-
10>Emitted(2, 74) Source(1, 18) + SourceIndex(0)
89-
11>Emitted(2, 100) Source(1, 23) + SourceIndex(0)
97+
7 >Emitted(2, 35) Source(1, 12) + SourceIndex(0)
98+
8 >Emitted(2, 54) Source(1, 15) + SourceIndex(0)
99+
9 >Emitted(2, 55) Source(1, 16) + SourceIndex(0)
100+
10>Emitted(2, 60) Source(1, 16) + SourceIndex(0)
101+
11>Emitted(2, 62) Source(1, 18) + SourceIndex(0)
102+
12>Emitted(2, 72) Source(1, 23) + SourceIndex(0)
103+
13>Emitted(2, 74) Source(1, 18) + SourceIndex(0)
104+
14>Emitted(2, 75) Source(1, 19) + SourceIndex(0)
105+
15>Emitted(2, 94) Source(1, 22) + SourceIndex(0)
106+
16>Emitted(2, 95) Source(1, 23) + SourceIndex(0)
107+
17>Emitted(2, 100) Source(1, 23) + SourceIndex(0)
90108
---
91109
>>> a;
92110
1 >^^^^

tests/baselines/reference/ES5For-of35.js.map

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

tests/baselines/reference/ES5For-of35.sourcemap.txt

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,51 @@ sourceFile:ES5For-of35.ts
7070
4 > ^^
7171
5 > ^^^^^^^^^
7272
6 > ^^
73-
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
74-
8 > ^^
75-
9 > ^^^^^^^^^
76-
10> ^^
77-
11> ^^^^^^^^^^^^^^^^^^^^^^^^^^
73+
7 > ^
74+
8 > ^^^^^^^^^^^^^^^^^^^
75+
9 > ^
76+
10> ^^^^^
77+
11> ^^
78+
12> ^^^^^^^^^
79+
13> ^^
80+
14> ^
81+
15> ^^^^^^^^^^^^^^^^^^^
82+
16> ^
83+
17> ^^^^^
7884
1->
7985
2 >
8086
3 > {x: a = 0, y: b = 1}
8187
4 >
8288
5 > x: a = 0
8389
6 >
84-
7 > x: a = 0
85-
8 > ,
86-
9 > y: b = 1
87-
10>
88-
11> y: b = 1
90+
7 > a
91+
8 > =
92+
9 > 0
93+
10>
94+
11> ,
95+
12> y: b = 1
96+
13>
97+
14> b
98+
15> =
99+
16> 1
100+
17>
89101
1->Emitted(15, 9) Source(1, 12) + SourceIndex(0)
90102
2 >Emitted(15, 13) Source(1, 12) + SourceIndex(0)
91103
3 >Emitted(15, 26) Source(1, 32) + SourceIndex(0)
92104
4 >Emitted(15, 28) Source(1, 13) + SourceIndex(0)
93105
5 >Emitted(15, 37) Source(1, 21) + SourceIndex(0)
94-
6 >Emitted(15, 39) Source(1, 13) + SourceIndex(0)
95-
7 >Emitted(15, 65) Source(1, 21) + SourceIndex(0)
96-
8 >Emitted(15, 67) Source(1, 23) + SourceIndex(0)
97-
9 >Emitted(15, 76) Source(1, 31) + SourceIndex(0)
98-
10>Emitted(15, 78) Source(1, 23) + SourceIndex(0)
99-
11>Emitted(15, 104) Source(1, 31) + SourceIndex(0)
106+
6 >Emitted(15, 39) Source(1, 16) + SourceIndex(0)
107+
7 >Emitted(15, 40) Source(1, 17) + SourceIndex(0)
108+
8 >Emitted(15, 59) Source(1, 20) + SourceIndex(0)
109+
9 >Emitted(15, 60) Source(1, 21) + SourceIndex(0)
110+
10>Emitted(15, 65) Source(1, 21) + SourceIndex(0)
111+
11>Emitted(15, 67) Source(1, 23) + SourceIndex(0)
112+
12>Emitted(15, 76) Source(1, 31) + SourceIndex(0)
113+
13>Emitted(15, 78) Source(1, 26) + SourceIndex(0)
114+
14>Emitted(15, 79) Source(1, 27) + SourceIndex(0)
115+
15>Emitted(15, 98) Source(1, 30) + SourceIndex(0)
116+
16>Emitted(15, 99) Source(1, 31) + SourceIndex(0)
117+
17>Emitted(15, 104) Source(1, 31) + SourceIndex(0)
100118
---
101119
>>> a;
102120
1 >^^^^^^^^

0 commit comments

Comments
 (0)