mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 02:21:30 -05:00
Merge branch 'transforms' into transforms-removeExcludeFlags
This commit is contained in:
@@ -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 {
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
@@ -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;
|
||||
@@ -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),
|
||||
@@ -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
|
||||
)
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -769,7 +769,7 @@ namespace Harness {
|
||||
return response.responseText;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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, () => {
|
||||
|
||||
Reference in New Issue
Block a user