Skip to content

Commit e35dd79

Browse files
committed
[Transforms] Update baselines from merging with master round 2 (#8926)
* update baselines from merging with master * Correctly fix#8786 * Fix up linting errors * Fix spelling error in comment * Remove usage of null * Revert "Remove usage of null" This reverts commit d9102d1. * Disable using null in unittest as we use null to signal to not generate baselines * Remove setting disable comment as we already done so in createCommentWriter * Address linting * Fix travis failure * Fix travis failure
1 parent 0af375e commit e35dd79

File tree

12 files changed

+88
-92
lines changed

12 files changed

+88
-92
lines changed

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,8 @@ function runTestsAndWriteOutput(file, defaultSubsets) {
782782
subsets = [];
783783
subsetRegexes = [];
784784
negations = [];
785-
for (const subset of defaultSubsets) {
785+
for (var i = 0; i < defaultSubsets.length; ++i) {
786+
var subset = defaultSubsets[i];
786787
subsets.push(subset.name);
787788
subsetRegexes.push(subset.pattern);
788789
negations.push(subset.pattern);

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ namespace ts {
506506
container = saveContainer;
507507
blockScopeContainer = savedBlockScopeContainer;
508508
}
509-
509+
510510
function bindChildren(node: Node): void {
511511
if (skipTransformFlagAggregation) {
512512
bindChildrenWorker(node);

src/compiler/comments.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace ts {
2424
let currentLineMap: number[];
2525
let detachedCommentsInfo: { nodePos: number, detachedCommentEndPos: number}[];
2626
let hasWrittenComment = false;
27-
let hasLastComment: boolean;
28-
let lastCommentEnd: number;
2927
let disabled: boolean = compilerOptions.removeComments;
3028

3129
return {
@@ -287,7 +285,6 @@ namespace ts {
287285
currentText = currentSourceFile.text;
288286
currentLineMap = getLineStarts(currentSourceFile);
289287
detachedCommentsInfo = undefined;
290-
disabled = false;
291288
}
292289

293290
function disableCommentsAndEmit(node: Node, emitCallback: (node: Node) => void): void {

src/compiler/printer.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,6 @@ const _super = (function (geti, seti) {
389389
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoLeadingComments) !== 0;
390390
}
391391

392-
/**
393-
* Determines whether to skip trailing comment emit for a node.
394-
*
395-
* We do not emit comments for NotEmittedStatement nodes or any node that has
396-
* NodeEmitFlags.NoTrailingComments.
397-
*
398-
* @param node A Node.
399-
*/
400-
function shouldSkipTrailingCommentsForNode(node: Node) {
401-
return isNotEmittedStatement(node)
402-
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoTrailingComments) !== 0;
403-
}
404-
405392
/**
406393
* Determines whether to skip source map emit for the start position of a node.
407394
*
@@ -2897,7 +2884,7 @@ const _super = (function (geti, seti) {
28972884
// Other
28982885
PreferNewLine = 1 << 15, // Prefer adding a LineTerminator between synthesized nodes.
28992886
NoTrailingNewLine = 1 << 16, // Do not emit a trailing NewLine for a MultiLine list.
2900-
NoInterveningComments = 1 << 17,// Do not emit comments between each node
2887+
NoInterveningComments = 1 << 17, // Do not emit comments between each node
29012888

29022889
// Precomputed Formats
29032890
Modifiers = SingleLine | SpaceBetweenSiblings,

src/compiler/transformers/ts.ts

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -570,17 +570,17 @@ namespace ts {
570570
// ---------------------------------------------------------------------
571571
// TypeScript | Javascript
572572
// ---------------------------------------------------------------------
573-
// @dec | let C_1;
574-
// class C { | let C = C_1 = class C {
575-
// static x() { return C.y; } | static x() { return C_1.y; }
576-
// static y = 1; | }
573+
// @dec | let C_1 = class C {
574+
// class C { | static x() { return C_1.y; }
575+
// static x() { return C.y; } | }
576+
// static y = 1; | let C = C_1;
577577
// } | C.y = 1;
578578
// | C = C_1 = __decorate([dec], C);
579579
// ---------------------------------------------------------------------
580-
// @dec | let C_1;
581-
// export class C { | let C = C_1 = class C {
582-
// static x() { return C.y; } | static x() { return C_1.y; }
583-
// static y = 1; | }
580+
// @dec | let C_1 = class C {
581+
// export class C { | static x() { return C_1.y; }
582+
// static x() { return C.y; } | }
583+
// static y = 1; | let C = C_1;
584584
// } | C.y = 1;
585585
// | C = C_1 = __decorate([dec], C);
586586
// | export { C };
@@ -612,10 +612,10 @@ namespace ts {
612612
// ---------------------------------------------------------------------
613613
// TypeScript | Javascript
614614
// ---------------------------------------------------------------------
615-
// @dec | let C_1;
616-
// export default class C { | let C = C_1 = class C {
617-
// static x() { return C.y; } | static x() { return C_1.y; }
618-
// static y = 1; | }
615+
// @dec | let C_1 = class C {
616+
// export default class C { | static x() { return C_1.y; }
617+
// static x() { return C.y; } | }
618+
// static y = 1; | let C = C_1;
619619
// } | C.y = 1;
620620
// | C = C_1 = __decorate([dec], C);
621621
// | export default C;
@@ -627,7 +627,7 @@ namespace ts {
627627
// ... = class ${name} ${heritageClauses} {
628628
// ${members}
629629
// }
630-
let classExpression: Expression = setOriginalNode(
630+
const classExpression: Expression = setOriginalNode(
631631
createClassExpression(
632632
name,
633633
visitNodes(node.heritageClauses, visitor, isHeritageClause),
@@ -647,35 +647,19 @@ namespace ts {
647647
enableSubstitutionForDecoratedClasses();
648648
decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default");
649649
decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias;
650-
651-
// We emit the class alias as a `let` declaration here so that it has the same
652-
// TDZ as the class.
653-
654-
// let ${decoratedClassAlias};
655-
addNode(statements,
656-
createVariableStatement(
657-
/*modifiers*/ undefined,
658-
createLetDeclarationList([
659-
createVariableDeclaration(decoratedClassAlias)
660-
])
661-
)
662-
);
663-
664-
// ${decoratedClassAlias} = ${classExpression}
665-
classExpression = createAssignment(
666-
decoratedClassAlias,
667-
classExpression,
668-
/*location*/ location);
669650
}
670651

671-
// let ${name} = ${classExpression};
652+
const declaredName = getDeclarationName(node, /*allowComments*/ true);
653+
654+
// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
655+
// or decoratedClassAlias if the class contain self-reference.
672656
addNode(statements,
673657
setOriginalNode(
674658
createVariableStatement(
675659
/*modifiers*/ undefined,
676660
createLetDeclarationList([
677661
createVariableDeclaration(
678-
getDeclarationName(node, /*allowComments*/ true),
662+
decoratedClassAlias || declaredName,
679663
/*type*/ undefined,
680664
classExpression
681665
)
@@ -686,6 +670,29 @@ namespace ts {
686670
)
687671
);
688672

673+
if (decoratedClassAlias) {
674+
// We emit the class alias as a `let` declaration here so that it has the same
675+
// TDZ as the class.
676+
677+
// let ${declaredName} = ${decoratedClassAlias}
678+
addNode(statements,
679+
setOriginalNode(
680+
createVariableStatement(
681+
/*modifiers*/ undefined,
682+
createLetDeclarationList([
683+
createVariableDeclaration(
684+
declaredName,
685+
/*type*/ undefined,
686+
decoratedClassAlias
687+
)
688+
]),
689+
/*location*/ location
690+
),
691+
/*original*/ node
692+
)
693+
);
694+
}
695+
689696
return decoratedClassAlias;
690697
}
691698

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ namespace Harness {
769769
return response.responseText;
770770
}
771771
else {
772-
return null;
772+
return undefined;
773773
}
774774
}
775775

src/harness/projectsRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ class ProjectRunner extends RunnerBase {
472472

473473
it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
474474
if (testCase.baselineCheck) {
475-
var lastError: any = undefined;
475+
let lastError: any = undefined;
476476
ts.forEach(compilerResult.outputFiles, outputFile => {
477477
try {
478478
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {

tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
//// [computedPropertyNamesContextualType7_ES5.ts]
2-
interface I<T> {
3-
[n: number]: T;
4-
}
5-
interface J<T> {
6-
[s: string]: T;
7-
}
8-
9-
declare function foo<T>(obj: I<T>): T;
10-
declare function g<T>(obj: J<T>): T;
11-
12-
foo({
13-
0: () => { },
14-
["hi" + "bye"]: true,
15-
[0 + 1]: 0,
16-
[+"hi"]: [0]
17-
});
18-
19-
g({ p: "" });
2+
interface I<T> {
3+
[n: number]: T;
4+
}
5+
interface J<T> {
6+
[s: string]: T;
7+
}
8+
9+
declare function foo<T>(obj: I<T>): T;
10+
declare function g<T>(obj: J<T>): T;
11+
12+
foo({
13+
0: () => { },
14+
["hi" + "bye"]: true,
15+
[0 + 1]: 0,
16+
[+"hi"]: [0]
17+
});
18+
19+
g({ p: "" });
2020

2121

2222
//// [computedPropertyNamesContextualType7_ES5.js]

tests/baselines/reference/decoratorOnClass6.es6.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//// [decoratorOnClass6.es6.ts]
2-
declare function dec<T>(target: T): T;
3-
4-
@dec
5-
export class C {
6-
static x() { return C.y; }
7-
static y = 1;
8-
}
9-
2+
declare function dec<T>(target: T): T;
3+
4+
@dec
5+
export class C {
6+
static x() { return C.y; }
7+
static y = 1;
8+
}
9+
1010
let c = new C();
1111

1212
//// [decoratorOnClass6.es6.js]

tests/baselines/reference/parameterReferenceInInitializer1.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function fn(y, set) {
1919
var C = (function () {
2020
function C(y, x // expected to work, but actually doesn't
2121
) {
22-
if (x === void 0) { x = fn(y, function (y, x) { return y.x = x; }); }
23-
this.x = x;
22+
if (x === void 0) { x = fn(y, function (y, x) { return y.x = x; }); } // expected to work, but actually doesn't
23+
this.x = x; // expected to work, but actually doesn't
2424
}
2525
return C;
2626
}());

0 commit comments

Comments
 (0)