diff --git a/Jakefile.js b/Jakefile.js
index 7b9c4806e0a..d1821b5b5e0 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -223,6 +223,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);
@@ -285,6 +286,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(" ");
@@ -413,6 +417,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);
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index c65466f00de..307bb5d5403 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -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
}
];
diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index 3919e68aba5..357fec7f0fd 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -1915,6 +1915,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (multiLine) {
decreaseIndent();
+ if (!compilerOptions.transformCompatibleEmit) {
+ writeLine();
+ }
}
write(")");
@@ -4331,7 +4334,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);
@@ -5353,7 +5356,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();
@@ -5390,6 +5393,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 ");
@@ -5416,11 +5424,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();
diff --git a/src/compiler/program.ts b/src/compiler/program.ts
index f10c327faa7..87e8775d1f0 100644
--- a/src/compiler/program.ts
+++ b/src/compiler/program.ts
@@ -1,6 +1,7 @@
///
///
///
+///
namespace ts {
/* @internal */ export let programTime = 0;
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index 2348c4d2b03..6a55153f631 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -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;