Merge branch 'transforms-printer' into transforms-transformer-ts

This commit is contained in:
Ron Buckton 2016-02-23 13:15:52 -08:00
commit ad314b05f0
7 changed files with 37 additions and 10 deletions

View file

@ -239,6 +239,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
var useDebugMode = true;
var useTransforms = process.env.USE_TRANSFORMS || false;
var useTransformCompat = false;
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
var compilerFilename = "tsc.js";
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
@ -301,6 +302,9 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
if (useBuiltCompiler && useTransforms) {
options += " --experimentalTransforms"
}
else if (useBuiltCompiler && useTransformCompat) {
options += " --transformCompatibleEmit"
}
var cmd = host + " " + compilerPath + " " + options + " ";
cmd = cmd + sources.join(" ");
@ -429,6 +433,10 @@ task("setTransforms", function() {
useTransforms = true;
});
task("setTransformCompat", function() {
useTransformCompat = true;
});
task("configure-nightly", [configureNightlyJs], function() {
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
console.log(cmd);

View file

@ -322,9 +322,18 @@ namespace ts {
description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
},
{
// this option will be removed when this is merged with master and exists solely
// to enable the tree transforming emitter side-by-side with the existing emitter.
name: "experimentalTransforms",
type: "boolean",
experimental: true
},
{
// this option will be removed when this is merged with master and exists solely
// to enable the tree transforming emitter side-by-side with the existing emitter.
name: "transformCompatibleEmit",
type: "boolean",
experimental: true
}
];

View file

@ -1919,6 +1919,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (multiLine) {
decreaseIndent();
if (!compilerOptions.transformCompatibleEmit) {
writeLine();
}
}
write(")");
@ -4335,7 +4338,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
writeLine();
emitStart(restParam);
emitNodeWithCommentsAndWithoutSourcemap(restParam.name);
write(restIndex > 0
write(restIndex > 0 || !compilerOptions.transformCompatibleEmit
? `[${tempName} - ${restIndex}] = arguments[${tempName}];`
: `[${tempName}] = arguments[${tempName}];`);
emitEnd(restParam);
@ -5357,7 +5360,7 @@ const _super = (function (geti, seti) {
const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression;
let tempVariable: Identifier;
if (isClassExpressionWithStaticProperties) {
if (isClassExpressionWithStaticProperties && compilerOptions.transformCompatibleEmit) {
tempVariable = createAndRecordTempVariable(TempFlags.Auto);
write("(");
increaseIndent();
@ -5394,6 +5397,11 @@ const _super = (function (geti, seti) {
writeLine();
emitConstructor(node, baseTypeNode);
emitMemberFunctionsForES5AndLower(node);
if (!compilerOptions.transformCompatibleEmit) {
emitPropertyDeclarations(node, staticProperties);
writeLine();
emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined);
}
writeLine();
emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => {
write("return ");
@ -5420,11 +5428,13 @@ const _super = (function (geti, seti) {
write("))");
if (node.kind === SyntaxKind.ClassDeclaration) {
write(";");
emitPropertyDeclarations(node, staticProperties);
writeLine();
emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined);
if (compilerOptions.transformCompatibleEmit) {
emitPropertyDeclarations(node, staticProperties);
writeLine();
emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined);
}
}
else if (isClassExpressionWithStaticProperties) {
else if (isClassExpressionWithStaticProperties && compilerOptions.transformCompatibleEmit) {
for (const property of staticProperties) {
write(",");
writeLine();

View file

@ -1,6 +1,7 @@
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
/// <reference path="printer.ts" />
namespace ts {
/* @internal */ export let programTime = 0;

View file

@ -75,9 +75,7 @@ namespace ts {
}
currentSourceFile = sourceFile;
const visited = transformation(sourceFile);
currentSourceFile = undefined;
return visited;
return transformation(sourceFile);
}
function enableExpressionSubstitution(kind: SyntaxKind) {

View file

@ -2470,6 +2470,7 @@ namespace ts {
allowJs?: boolean;
/* @internal */ stripInternal?: boolean;
/* @internal */ experimentalTransforms?: boolean;
/* @internal */ transformCompatibleEmit?: boolean;
// Skip checking lib.d.ts to help speed up tests.
/* @internal */ skipDefaultLibCheck?: boolean;

View file

@ -204,7 +204,7 @@ namespace ts.formatting {
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
// - parent and child are not on the same line
let useActualIndentation =
(isDeclaration(current) || isStatement(current)) &&
(isDeclaration(current) || isStatementButNotDeclaration(current)) &&
(parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
if (!useActualIndentation) {