From 5443d309d54797298aac6ea42bbcf81cfc435e66 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Mar 2016 16:40:07 -0700 Subject: [PATCH 1/4] Fixed multiline block for async functions --- src/compiler/transformers/ts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index c49cdc49821..9ddc83ca3b9 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2004,7 +2004,7 @@ namespace ts { ) ); - const block = createBlock(statements, /*location*/ node.body); + const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. From e50469948f13ac2a862a67cc1496cc51de3b97ef Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Mar 2016 17:03:49 -0700 Subject: [PATCH 2/4] Fix async method with super --- Jakefile.js | 4 ++++ src/compiler/transformers/ts.ts | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index ed4751c47f4..b13e2cfacf9 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -695,6 +695,7 @@ function runTestsAndWriteOutput(file) { cleanTestDirs(); var tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; + var beep = process.env.beep; var testConfigFile = 'test.config'; if (fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); @@ -790,6 +791,8 @@ function runTestsAndWriteOutput(file) { console.log(comments.join(os.EOL)); deleteTemporaryProjectOutput(); complete(); + + if (beep) process.stdout.write("\u0007"); }); ex.addListener("error", function (e, status) { if (progress.visible) { @@ -804,6 +807,7 @@ function runTestsAndWriteOutput(file) { } deleteTemporaryProjectOutput(); + if (beep) process.stdout.write("\u0007"); fail("Process exited with code " + status); }); ex.run(); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 9ddc83ca3b9..922a56697ae 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1793,11 +1793,14 @@ namespace ts { return undefined; } - return createMethod( - visitNodes(node.modifiers, visitor, isModifier), - visitPropertyNameOfClassElement(node), - visitNodes(node.parameters, visitor, isParameter), - transformFunctionBody(node), + return setOriginalNode( + createMethod( + visitNodes(node.modifiers, visitor, isModifier), + visitPropertyNameOfClassElement(node), + visitNodes(node.parameters, visitor, isParameter), + transformFunctionBody(node), + node + ), node ); } From 816467ceead8e6fab055ac788a0c0c018eaad30d Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Mar 2016 17:21:09 -0700 Subject: [PATCH 3/4] Elides functions with invalid bodies. --- src/compiler/transformers/ts.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 922a56697ae..19e317b6cba 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1903,6 +1903,10 @@ namespace ts { * @param node The function expression node. */ function visitFunctionExpression(node: FunctionExpression) { + if (nodeIsMissing(node.body)) { + return createNode(SyntaxKind.OmittedExpression); + } + return createFunctionExpression( node.asteriskToken, node.name, @@ -1919,7 +1923,7 @@ namespace ts { * @param node The declaration node. */ function shouldElideFunctionLikeDeclaration(node: FunctionLikeDeclaration) { - return node.body === undefined + return nodeIsMissing(node.body) || hasModifier(node, ModifierFlags.Abstract | ModifierFlags.Ambient); } From 6ba1961ce8ddd64a7e4de20f08cb21bc5388e0af Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 24 Mar 2016 17:48:31 -0700 Subject: [PATCH 4/4] Fixes elision of import declarations in ES6 modules. --- Jakefile.js | 9 +++++++++ src/compiler/transformers/module/es6.ts | 26 +++++++++++++++++++++++++ src/compiler/utilities.ts | 1 + 3 files changed, 36 insertions(+) diff --git a/Jakefile.js b/Jakefile.js index b13e2cfacf9..0c764758240 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -727,6 +727,7 @@ function runTestsAndWriteOutput(file) { var tapNotOk = /^not\sok/; var tapComment = /^#/; var typeError = /^\s+TypeError:/; + var debugError = /^\s+Error:\sDebug\sFailure\./; var progress = new ProgressBar("Running tests..."); var expectedTestCount = 0; var testCount = 0; @@ -734,6 +735,7 @@ function runTestsAndWriteOutput(file) { var successCount = 0; var comments = []; var typeErrorCount = 0; + var debugErrorCount = 0; ex.addListener("stdout", function (output) { var m = tapRange.exec(output); @@ -757,6 +759,9 @@ function runTestsAndWriteOutput(file) { else if (typeError.test(output)) { typeErrorCount++; } + else if (debugError.test(output)) { + debugErrorCount++; + } return; } @@ -806,6 +811,10 @@ function runTestsAndWriteOutput(file) { console.log("# type errors: %s", typeErrorCount); } + if (debugErrorCount) { + console.log("# debug errors: %s", debugErrorCount); + } + deleteTemporaryProjectOutput(); if (beep) process.stdout.write("\u0007"); fail("Process exited with code " + status); diff --git a/src/compiler/transformers/module/es6.ts b/src/compiler/transformers/module/es6.ts index 63b147b6e60..f513ac36dbb 100644 --- a/src/compiler/transformers/module/es6.ts +++ b/src/compiler/transformers/module/es6.ts @@ -4,9 +4,35 @@ /*@internal*/ namespace ts { export function transformES6Module(context: TransformationContext) { + const compilerOptions = context.getCompilerOptions(); + const resolver = context.getEmitResolver(); + + let currentSourceFile: SourceFile; + return transformSourceFile; function transformSourceFile(node: SourceFile) { + if (isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + return visitEachChild(node, visitor, context); + } + return node; + } + + function visitor(node: Node) { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + return visitImportDeclaration(node); + } + + return node; + } + + function visitImportDeclaration(node: ImportDeclaration) { + if (node.importClause && !resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { + return undefined; + } + return node; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 18a95bc5ff0..aedd44fcb6a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3405,6 +3405,7 @@ namespace ts { || kind === SyntaxKind.TypeAliasDeclaration || kind === SyntaxKind.EnumDeclaration || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.ImportDeclaration || kind === SyntaxKind.ImportEqualsDeclaration || kind === SyntaxKind.ExportDeclaration || kind === SyntaxKind.ExportAssignment;