Skip to content

[Transforms] Makes transforms the default #7948

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 1 commit into from
Apr 8, 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
4 changes: 2 additions & 2 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
options += " --stripInternal"
}

if (useBuiltCompiler && Boolean(process.env.USE_TRANSFORMS)) {
console.warn("\u001b[93mwarning: Found 'USE_TRANSFORMS' environment variable. Experimental transforms will be enabled by default.\u001b[0m");
if (useBuiltCompiler && !/^(no?|f(alse)?|0|-)$/i.test(process.env.USE_TRANSFORMS)) {
console.warn("\u001b[93mwarning: 'USE_TRANSFORMS' environment variable is not set to 'false'. Experimental transforms will be enabled by default.\u001b[0m");
}

var cmd = host + " " + compilerPath + " " + options + " ";
Expand Down
7 changes: 3 additions & 4 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,10 @@ namespace ts {
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
},
{
// 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",
name: "useLegacyEmitter",
type: "boolean",
experimental: true
experimental: true,
description: Diagnostics.Use_the_legacy_emitter_instead_of_the_transforming_emitter
}
];

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,11 @@ namespace ts {
return currentAssertionLevel;
}

const developmentMode = sys && /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"));
if (developmentMode === undefined) {
if (sys === undefined) {
return AssertionLevel.None;
}

const developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV"));
currentAssertionLevel = developmentMode
? AssertionLevel.Normal
: AssertionLevel.None;
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,10 @@
"category": "Message",
"code": 6112
},
"Use the legacy emitter instead of the transforming emitter.": {
"category": "Message",
"code": 6113
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
"code": 7005
Expand Down
9 changes: 5 additions & 4 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ namespace ts {
readFile: fileName => sys.readFile(fileName),
trace: (s: string) => sys.write(s + newLine),
directoryExists: directoryName => sys.directoryExists(directoryName),
getEnvironmentVariable: sys.getEnvironmentVariable
getEnvironmentVariable: name => getEnvironmentVariable(name, /*host*/ undefined)
};
}

Expand Down Expand Up @@ -996,11 +996,12 @@ namespace ts {
const start = new Date().getTime();

// TODO(rbuckton): remove USE_TRANSFORMS condition when we switch to transforms permanently.
if (/^(y(es)?|t(rue|ransforms?)?|1|\+)$/i.test(getEnvironmentVariable("USE_TRANSFORMS", host))) {
options.experimentalTransforms = true;
let useLegacyEmitter = options.useLegacyEmitter;
if (/^(no?|f(alse)?|0|-)$/i.test(getEnvironmentVariable("USE_TRANSFORMS", host))) {
useLegacyEmitter = true;
}

const fileEmitter = options.experimentalTransforms ? printFiles : emitFiles;
const fileEmitter = useLegacyEmitter ? emitFiles : printFiles;
const emitResult = fileEmitter(
emitResolver,
getEmitHost(writeFileCallback),
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,7 @@ namespace ts {
noImplicitUseStrict?: boolean;
lib?: string[];
/* @internal */ stripInternal?: boolean;
/* @internal */ experimentalTransforms?: boolean;
/* @internal */ useLegacyEmitter?: boolean;

// Skip checking lib.d.ts to help speed up tests.
/* @internal */ skipDefaultLibCheck?: boolean;
Expand Down