diff --git a/Jakefile.js b/Jakefile.js index ed4751c47f4..0c764758240 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); @@ -726,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; @@ -733,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); @@ -756,6 +759,9 @@ function runTestsAndWriteOutput(file) { else if (typeError.test(output)) { typeErrorCount++; } + else if (debugError.test(output)) { + debugErrorCount++; + } return; } @@ -790,6 +796,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) { @@ -803,7 +811,12 @@ 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); }); ex.run(); 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/transformers/ts.ts b/src/compiler/transformers/ts.ts index c49cdc49821..19e317b6cba 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 ); } @@ -1900,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, @@ -1916,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); } @@ -2004,7 +2011,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. 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;