mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
Merge branch 'transforms' into transforms-removeExcludeFlags
This commit is contained in:
commit
d4ed1ba4b2
@ -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);
|
||||
|
||||
@ -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, () => {
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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;
|
||||
}());
|
||||
|
||||
@ -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) {
|
||||
@ -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",
|
||||
@ -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
|
||||
*/`);
|
||||
|
||||
@ -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);
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user