Merge branch 'feature/noEmitExtends' of https://github.com/whitneyit/TypeScript into whitneyit-feature/noEmitExtends

This commit is contained in:
Mohamed Hegazy
2015-05-01 16:04:04 -07:00
10 changed files with 80 additions and 16 deletions

View File

@@ -71,6 +71,10 @@ module ts {
type: "boolean",
description: Diagnostics.Do_not_emit_outputs,
},
{
name: "noEmitHelpers",
type: "boolean"
},
{
name: "noEmitOnError",
type: "boolean",

View File

@@ -5487,6 +5487,9 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
}
write("[\"require\", \"exports\"");
if (compilerOptions.noEmitHelpers) {
write(", \"__extends\"");
}
if (aliasedModuleNames.length) {
write(", ");
write(aliasedModuleNames.join(", "));
@@ -5496,6 +5499,9 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
write(unaliasedModuleNames.join(", "));
}
write("], function (require, exports");
if (compilerOptions.noEmitHelpers) {
write(", __extends");
}
if (importAliasNames.length) {
write(", ");
write(importAliasNames.join(", "));
@@ -5614,24 +5620,30 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
// emit prologue directives prior to __extends
var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
// Only Emit __extends function when target ES5.
// For target ES6 and above, we can emit classDeclaration as is.
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) {
writeLines(extendsHelper);
extendsEmitted = true;
}
if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) {
writeLines(decorateHelper);
if (compilerOptions.emitDecoratorMetadata) {
writeLines(metadataHelper);
// Only emit helpers if the user did not say otherwise.
if (!compilerOptions.noEmitHelpers) {
// Only Emit __extends function when target ES5.
// For target ES6 and above, we can emit classDeclaration as is.
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) {
writeLines(extendsHelper);
extendsEmitted = true;
}
if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) {
writeLines(decorateHelper);
if (compilerOptions.emitDecoratorMetadata) {
writeLines(metadataHelper);
}
decorateEmitted = true;
}
if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) {
writeLines(paramHelper);
paramEmitted = true;
}
decorateEmitted = true;
}
if (!paramEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitParam) {
writeLines(paramHelper);
paramEmitted = true;
}
if (isExternalModule(node) || compilerOptions.separateCompilation) {

View File

@@ -1657,6 +1657,7 @@ module ts {
mapRoot?: string;
module?: ModuleKind;
noEmit?: boolean;
noEmitHelpers?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
noImplicitAny?: boolean;

View File

@@ -990,6 +990,10 @@ module Harness {
}
break;
case 'noemithelpers':
options.noEmitHelpers = !!setting.value;
break;
case 'noemitonerror':
options.noEmitOnError = !!setting.value;
break;
@@ -1477,7 +1481,7 @@ module Harness {
// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module",
"nolib", "sourcemap", "target", "out", "outdir", "noemitonerror",
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
"noimplicitany", "noresolve", "newline", "newlines", "emitbom",
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",