Fixes elision of import declarations in ES6 modules.

This commit is contained in:
Ron Buckton 2016-03-24 17:48:31 -07:00
parent 816467ceea
commit 6ba1961ce8
3 changed files with 36 additions and 0 deletions

View file

@ -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);

View file

@ -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(<ImportDeclaration>node);
}
return node;
}
function visitImportDeclaration(node: ImportDeclaration) {
if (node.importClause && !resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) {
return undefined;
}
return node;
}
}

View file

@ -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;