Skip to content

[Transforms] Update baselines from merging with master round 2 #8926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ function runTestsAndWriteOutput(file, defaultSubsets) {
subsets = [];
subsetRegexes = [];
negations = [];
for (const subset of defaultSubsets) {
for (var i = 0; i < defaultSubsets.length; ++i) {
var subset = defaultSubsets[i];
subsets.push(subset.name);
subsetRegexes.push(subset.pattern);
negations.push(subset.pattern);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ namespace ts {
container = saveContainer;
blockScopeContainer = savedBlockScopeContainer;
}

function bindChildren(node: Node): void {
if (skipTransformFlagAggregation) {
bindChildrenWorker(node);
Expand Down
3 changes: 0 additions & 3 deletions src/compiler/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ namespace ts {
let currentLineMap: number[];
let detachedCommentsInfo: { nodePos: number, detachedCommentEndPos: number}[];
let hasWrittenComment = false;
let hasLastComment: boolean;
let lastCommentEnd: number;
let disabled: boolean = compilerOptions.removeComments;

return {
Expand Down Expand Up @@ -287,7 +285,6 @@ namespace ts {
currentText = currentSourceFile.text;
currentLineMap = getLineStarts(currentSourceFile);
detachedCommentsInfo = undefined;
disabled = false;
}

function disableCommentsAndEmit(node: Node, emitCallback: (node: Node) => void): void {
Expand Down
15 changes: 1 addition & 14 deletions src/compiler/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,6 @@ const _super = (function (geti, seti) {
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoLeadingComments) !== 0;
}

/**
* Determines whether to skip trailing comment emit for a node.
*
* We do not emit comments for NotEmittedStatement nodes or any node that has
* NodeEmitFlags.NoTrailingComments.
*
* @param node A Node.
*/
function shouldSkipTrailingCommentsForNode(node: Node) {
return isNotEmittedStatement(node)
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoTrailingComments) !== 0;
}

/**
* Determines whether to skip source map emit for the start position of a node.
*
Expand Down Expand Up @@ -2897,7 +2884,7 @@ const _super = (function (geti, seti) {
// Other
PreferNewLine = 1 << 15, // Prefer adding a LineTerminator between synthesized nodes.
NoTrailingNewLine = 1 << 16, // Do not emit a trailing NewLine for a MultiLine list.
NoInterveningComments = 1 << 17,// Do not emit comments between each node
NoInterveningComments = 1 << 17, // Do not emit comments between each node

// Precomputed Formats
Modifiers = SingleLine | SpaceBetweenSiblings,
Expand Down
75 changes: 41 additions & 34 deletions src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,17 @@ namespace ts {
// ---------------------------------------------------------------------
// TypeScript | Javascript
// ---------------------------------------------------------------------
// @dec | let C_1;
// class C { | let C = C_1 = class C {
// static x() { return C.y; } | static x() { return C_1.y; }
// static y = 1; | }
// @dec | let C_1 = class C {
// class C { | static x() { return C_1.y; }
// static x() { return C.y; } | }
// static y = 1; | let C = C_1;
// } | C.y = 1;
// | C = C_1 = __decorate([dec], C);
// ---------------------------------------------------------------------
// @dec | let C_1;
// export class C { | let C = C_1 = class C {
// static x() { return C.y; } | static x() { return C_1.y; }
// static y = 1; | }
// @dec | let C_1 = class C {
// export class C { | static x() { return C_1.y; }
// static x() { return C.y; } | }
// static y = 1; | let C = C_1;
// } | C.y = 1;
// | C = C_1 = __decorate([dec], C);
// | export { C };
Expand Down Expand Up @@ -612,10 +612,10 @@ namespace ts {
// ---------------------------------------------------------------------
// TypeScript | Javascript
// ---------------------------------------------------------------------
// @dec | let C_1;
// export default class C { | let C = C_1 = class C {
// static x() { return C.y; } | static x() { return C_1.y; }
// static y = 1; | }
// @dec | let C_1 = class C {
// export default class C { | static x() { return C_1.y; }
// static x() { return C.y; } | }
// static y = 1; | let C = C_1;
// } | C.y = 1;
// | C = C_1 = __decorate([dec], C);
// | export default C;
Expand All @@ -627,7 +627,7 @@ namespace ts {
// ... = class ${name} ${heritageClauses} {
// ${members}
// }
let classExpression: Expression = setOriginalNode(
const classExpression: Expression = setOriginalNode(
createClassExpression(
name,
visitNodes(node.heritageClauses, visitor, isHeritageClause),
Expand All @@ -647,35 +647,19 @@ namespace ts {
enableSubstitutionForDecoratedClasses();
decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default");
decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias;

// We emit the class alias as a `let` declaration here so that it has the same
// TDZ as the class.

// let ${decoratedClassAlias};
addNode(statements,
createVariableStatement(
/*modifiers*/ undefined,
createLetDeclarationList([
createVariableDeclaration(decoratedClassAlias)
])
)
);

// ${decoratedClassAlias} = ${classExpression}
classExpression = createAssignment(
decoratedClassAlias,
classExpression,
/*location*/ location);
}

// let ${name} = ${classExpression};
const declaredName = getDeclarationName(node, /*allowComments*/ true);

// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
// or decoratedClassAlias if the class contain self-reference.
addNode(statements,
setOriginalNode(
createVariableStatement(
/*modifiers*/ undefined,
createLetDeclarationList([
createVariableDeclaration(
getDeclarationName(node, /*allowComments*/ true),
decoratedClassAlias || declaredName,
/*type*/ undefined,
classExpression
)
Expand All @@ -686,6 +670,29 @@ namespace ts {
)
);

if (decoratedClassAlias) {
// We emit the class alias as a `let` declaration here so that it has the same
// TDZ as the class.

// let ${declaredName} = ${decoratedClassAlias}
addNode(statements,
setOriginalNode(
createVariableStatement(
/*modifiers*/ undefined,
createLetDeclarationList([
createVariableDeclaration(
declaredName,
/*type*/ undefined,
decoratedClassAlias
)
]),
/*location*/ location
),
/*original*/ node
)
);
}

return decoratedClassAlias;
}

Expand Down
2 changes: 1 addition & 1 deletion src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ namespace Harness {
return response.responseText;
}
else {
return null;
return undefined;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class ProjectRunner extends RunnerBase {

it("Baseline of emitted result (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
if (testCase.baselineCheck) {
var lastError: any = undefined;
let lastError: any = undefined;
ts.forEach(compilerResult.outputFiles, outputFile => {
try {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
//// [computedPropertyNamesContextualType7_ES5.ts]
interface I<T> {
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}
declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;
foo({
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});
g({ p: "" });
interface I<T> {
[n: number]: T;
}
interface J<T> {
[s: string]: T;
}

declare function foo<T>(obj: I<T>): T;
declare function g<T>(obj: J<T>): T;

foo({
0: () => { },
["hi" + "bye"]: true,
[0 + 1]: 0,
[+"hi"]: [0]
});

g({ p: "" });


//// [computedPropertyNamesContextualType7_ES5.js]
Expand Down
16 changes: 8 additions & 8 deletions tests/baselines/reference/decoratorOnClass6.es6.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//// [decoratorOnClass6.es6.ts]
declare function dec<T>(target: T): T;
@dec
export class C {
static x() { return C.y; }
static y = 1;
}
declare function dec<T>(target: T): T;

@dec
export class C {
static x() { return C.y; }
static y = 1;
}

let c = new C();

//// [decoratorOnClass6.es6.js]
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/parameterReferenceInInitializer1.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function fn(y, set) {
var C = (function () {
function C(y, x // expected to work, but actually doesn't
) {
if (x === void 0) { x = fn(y, function (y, x) { return y.x = x; }); }
this.x = x;
if (x === void 0) { x = fn(y, function (y, x) { return y.x = x; }); } // expected to work, but actually doesn't
this.x = x; // expected to work, but actually doesn't
}
return C;
}());
18 changes: 9 additions & 9 deletions tests/cases/unittests/jsDocParsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <reference path="..\..\..\src\compiler\parser.ts" />
/// <reference path="..\..\..\src\harness\harness.ts" />

module ts {
namespace ts {
describe("JSDocParsing", () => {
describe("TypeExpressions", () => {
function parsesCorrectly(name: string, content: string) {
Expand Down Expand Up @@ -95,10 +95,10 @@ module ts {
it(name, () => {
const comment = parseIsolatedJSDocComment(content);
if (!comment) {
Debug.fail('Comment failed to parse entirely');
Debug.fail("Comment failed to parse entirely");
}
if (comment.diagnostics.length > 0) {
Debug.fail('Comment has at least one diagnostic: ' + comment.diagnostics[0].messageText);
Debug.fail("Comment has at least one diagnostic: " + comment.diagnostics[0].messageText);
}

Harness.Baseline.runBaseline("parseCorrectly", "JSDocParsing/DocComments.parsesCorrectly." + name + ".json",
Expand All @@ -118,29 +118,29 @@ module ts {
parsesIncorrectly("emptyComment", "/***/");
parsesIncorrectly("threeAsterisks", "/*** */");
parsesIncorrectly("asteriskAfterPreamble", "/** * @type {number} */");
parsesIncorrectly("multipleTypes",
parsesIncorrectly("multipleTypes",
`/**
* @type {number}
* @type {string}
*/`);
parsesIncorrectly("multipleReturnTypes",
parsesIncorrectly("multipleReturnTypes",
`/**
* @return {number}
* @return {string}
*/`);
parsesIncorrectly("noTypeParameters",
parsesIncorrectly("noTypeParameters",
`/**
* @template
*/`);
parsesIncorrectly("trailingTypeParameterComma",
parsesIncorrectly("trailingTypeParameterComma",
`/**
* @template T,
*/`);
parsesIncorrectly("paramWithoutName",
parsesIncorrectly("paramWithoutName",
`/**
* @param {number}
*/`);
parsesIncorrectly("paramWithoutTypeOrName",
parsesIncorrectly("paramWithoutTypeOrName",
`/**
* @param
*/`);
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/unittests/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ namespace ts {
it("Correct errors for " + justName, () => {
Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".errors.txt"), () => {
if (transpileResult.diagnostics.length === 0) {
/* tslint:disable:no-null-keyword */
return null;
/* tslint:enable:no-null-keyword */
}

return Harness.Compiler.getErrorBaseline(toBeCompiled, transpileResult.diagnostics);
Expand All @@ -75,7 +77,9 @@ namespace ts {
it("Correct errors (old transpile) for " + justName, () => {
Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => {
if (oldTranspileDiagnostics.length === 0) {
/* tslint:disable:no-null-keyword */
return null;
/* tslint:enable:no-null-keyword */
}

return Harness.Compiler.getErrorBaseline(toBeCompiled, oldTranspileDiagnostics);
Expand Down