Skip to content

Commit 4db1448

Browse files
committed
Merge branch 'transforms' into transforms-fixPerformance
2 parents e64724e + 3305e9c commit 4db1448

330 files changed

Lines changed: 1380 additions & 1613 deletions

File tree

Some content is hidden

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

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,8 +2172,8 @@ namespace ts {
21722172
// A GetAccessor or SetAccessor is ES5 syntax.
21732173
excludeFlags = TransformFlags.MethodOrAccessorExcludes;
21742174

2175-
// A GetAccessor or SetAccessor is TypeScript syntax if it is either abstract,
2176-
// or has a decorator.
2175+
// A GetAccessor or SetAccessor is TypeScript syntax if it has async or abstract
2176+
// modifiers, or has a decorator.
21772177
if ((<AccessorDeclaration>node).body === undefined
21782178
|| hasModifier(node, ModifierFlags.Async | ModifierFlags.Abstract)
21792179
|| subtreeFlags & TransformFlags.ContainsDecorators) {

src/compiler/factory.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,6 @@ namespace ts {
11831183
const right = getMutableClone(node.right);
11841184
return createPropertyAccess(left, right, /*location*/ node);
11851185
}
1186-
else if (isIdentifier(node)) {
1187-
return getMutableClone(node);
1188-
}
11891186
else {
11901187
return getMutableClone(node);
11911188
}

src/compiler/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const _super = (function (geti, seti) {
220220

221221
// Write the source map
222222
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
223-
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), compilerOptions.emitBOM);
223+
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false);
224224
}
225225

226226
// Record source map data for the test harness.

src/compiler/transformers/module/module.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,6 @@ namespace ts {
698698
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
699699
const statements: Statement[] = [];
700700
const name = node.name || getGeneratedNameForNode(node);
701-
// Set emitFlags on the name of the classDeclaration
702-
// This is so that when printer will not substitute the identifier
703-
setNodeEmitFlags(name, NodeEmitFlags.NoSubstitution);
704701
if (hasModifier(node, ModifierFlags.Export)) {
705702
statements.push(
706703
setOriginalNode(

src/compiler/transformers/ts.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ namespace ts {
228228
if (hasModifier(node, ModifierFlags.Ambient) && isStatement(node)) {
229229
// TypeScript ambient declarations are elided, but some comments may be preserved.
230230
// See the implementation of `getLeadingComments` in comments.ts for more details.
231-
return isStatement(node)
232-
? createNotEmittedStatement(node)
233-
: undefined;
231+
return createNotEmittedStatement(node);
234232
}
235233

236234
switch (node.kind) {
@@ -430,16 +428,19 @@ namespace ts {
430428

431429
const constructor = getFirstConstructorWithBody(node);
432430
if (constructor) {
433-
for (const parameter of constructor.parameters) {
434-
if (parameter.decorators && parameter.decorators.length > 0) {
435-
return true;
436-
}
437-
}
431+
return forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
438432
}
439433

440434
return false;
441435
}
442436

437+
/**
438+
* Tests whether we should emit a __decorate call for a parameter declaration.
439+
*/
440+
function shouldEmitDecorateCallForParameter(parameter: ParameterDeclaration) {
441+
return parameter.decorators !== undefined && parameter.decorators.length > 0;
442+
}
443+
443444
/**
444445
* Transforms a class declaration with TypeScript syntax into compatible ES6.
445446
*

src/harness/compilerRunner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {
156156
if (options.sourceMap || options.inlineSourceMap) {
157157
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => {
158158
const record = result.getSourceMapRecord();
159-
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
159+
if ((options.noEmitOnError && result.errors.length !== 0) || record === undefined) {
160160
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required.
161161
return null;
162162
}
@@ -232,7 +232,7 @@ class CompilerBaselineRunner extends RunnerBase {
232232
}
233233

234234
Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => {
235-
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
235+
if ((options.noEmitOnError && result.errors.length !== 0) || result.sourceMaps.length === 0) {
236236
// We need to return null here or the runBaseLine will actually create a empty file.
237237
// Baselining isn't required here because there is no output.
238238
return null;

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ namespace Harness {
14321432
}
14331433

14341434
public getSourceMapRecord() {
1435-
if (this.sourceMapData) {
1435+
if (this.sourceMapData.length > 0) {
14361436
return Harness.SourceMapRecorder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
14371437
}
14381438
}

tests/baselines/reference/computedPropertyNamesSourceMap2_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/computedPropertyNamesSourceMap2_ES5.sourcemap.txt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,28 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
1212
1 >
1313
2 >^^^^
1414
3 > ^
15-
4 > ^^^
16-
5 > ^^^^^^^^^^^^^^^^^^^^^^^^->
15+
4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1716
1 >
1817
2 >var
1918
3 > v
20-
4 > =
2119
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2220
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
2321
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
24-
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
2522
---
2623
>>> _a["hello"] = function () {
2724
1->^^^^
2825
2 > ^^^
2926
3 > ^^^^^^^
30-
4 > ^
31-
5 > ^^^
32-
1->{
27+
4 > ^^^^
28+
1-> = {
3329
>
3430
2 > [
3531
3 > "hello"
36-
4 > ]
37-
5 >
32+
4 >
3833
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
3934
2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0)
4035
3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
41-
4 >Emitted(2, 16) Source(2, 14) + SourceIndex(0)
42-
5 >Emitted(2, 19) Source(2, 5) + SourceIndex(0)
36+
4 >Emitted(2, 19) Source(2, 5) + SourceIndex(0)
4337
---
4438
>>> debugger;
4539
1 >^^^^^^^^

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