mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Fix issue of the default binding not elided if namedImport is reference
Conflicts: src/compiler/checker.ts src/compiler/emitter.ts tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js
This commit is contained in:
parent
b6a6d85e6b
commit
c984e81053
@ -11033,7 +11033,6 @@ module ts {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return forEachChild(node, isReferencedAliasDeclaration);
|
||||
}
|
||||
|
||||
function isImplementationOfOverload(node: FunctionLikeDeclaration) {
|
||||
|
||||
@ -5061,7 +5061,7 @@ module ts {
|
||||
// ES6 import
|
||||
if (node.importClause) {
|
||||
let shouldEmitDefaultBindings = node.importClause.name && resolver.isReferencedAliasDeclaration(node.importClause);
|
||||
let shouldEmitNamedBindings = hasReferencedNamedBindings();
|
||||
let shouldEmitNamedBindings = hasReferencedNamedBindings(node.importClause);
|
||||
if (shouldEmitDefaultBindings || shouldEmitNamedBindings) {
|
||||
write("import ");
|
||||
emitStart(node.importClause);
|
||||
@ -5109,16 +5109,16 @@ module ts {
|
||||
emit(node.moduleSpecifier);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
|
||||
function hasReferencedNamedBindings() {
|
||||
if (node.importClause.namedBindings) {
|
||||
if (node.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
return resolver.isReferencedAliasDeclaration(node.importClause.namedBindings);
|
||||
}
|
||||
else {
|
||||
return forEach((<NamedImports>node.importClause.namedBindings).elements,
|
||||
namedImport => resolver.isReferencedAliasDeclaration(namedImport));
|
||||
}
|
||||
function hasReferencedNamedBindings(importClause: ImportClause) {
|
||||
if (importClause && importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
return resolver.isReferencedAliasDeclaration(importClause.namedBindings);
|
||||
}
|
||||
else {
|
||||
return forEach((<NamedImports>importClause.namedBindings).elements,
|
||||
namedImport => resolver.isReferencedAliasDeclaration(namedImport));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5262,35 +5262,43 @@ module ts {
|
||||
function createExternalImportInfo(node: Node): ExternalImportInfo {
|
||||
if (node.kind === SyntaxKind.ImportEqualsDeclaration) {
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
return {
|
||||
rootNode: <ImportEqualsDeclaration>node,
|
||||
declarationNode: <ImportEqualsDeclaration>node
|
||||
};
|
||||
if (resolver.isReferencedAliasDeclaration(node)) {
|
||||
return {
|
||||
rootNode: <ImportEqualsDeclaration>node,
|
||||
declarationNode: <ImportEqualsDeclaration>node
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ImportDeclaration) {
|
||||
let importClause = (<ImportDeclaration>node).importClause;
|
||||
if (importClause) {
|
||||
if (importClause.name) {
|
||||
if (importClause.name && resolver.isReferencedAliasDeclaration(importClause)) {
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node,
|
||||
declarationNode: importClause
|
||||
};
|
||||
}
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node,
|
||||
declarationNode: <NamespaceImport>importClause.namedBindings
|
||||
};
|
||||
if (hasReferencedNamedBindings(importClause)) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node,
|
||||
declarationNode: <NamespaceImport>importClause.namedBindings
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node,
|
||||
namedImports: <NamedImports>importClause.namedBindings,
|
||||
localName: resolver.getGeneratedNameForNode(<ImportDeclaration>node)
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node,
|
||||
namedImports: <NamedImports>importClause.namedBindings,
|
||||
localName: resolver.getGeneratedNameForNode(<ImportDeclaration>node)
|
||||
};
|
||||
}
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node
|
||||
else {
|
||||
return {
|
||||
rootNode: <ImportDeclaration>node
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ExportDeclaration) {
|
||||
@ -5327,9 +5335,7 @@ module ts {
|
||||
else {
|
||||
let info = createExternalImportInfo(node);
|
||||
if (info) {
|
||||
if ((!info.declarationNode && !info.namedImports) || resolver.isReferencedAliasDeclaration(node)) {
|
||||
externalImports.push(info);
|
||||
}
|
||||
externalImports.push(info);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -62,16 +62,16 @@ var x11 = (function () {
|
||||
})();
|
||||
exports.x11 = x11;
|
||||
//// [client.js]
|
||||
var defaultBinding2 = require("server");
|
||||
var _server_1 = require("server");
|
||||
exports.x1 = new _server_1.a();
|
||||
var defaultBinding3 = require("server");
|
||||
var _server_2 = require("server");
|
||||
exports.x2 = new _server_2.a11();
|
||||
var defaultBinding4 = require("server");
|
||||
var _server_3 = require("server");
|
||||
exports.x4 = new _server_3.x();
|
||||
exports.x5 = new _server_3.a12();
|
||||
var defaultBinding5 = require("server");
|
||||
var _server_4 = require("server");
|
||||
exports.x3 = new _server_4.x11();
|
||||
var defaultBinding6 = require("server");
|
||||
var _server_5 = require("server");
|
||||
exports.x6 = new _server_5.m();
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ var x: number = nameSpaceBinding.a;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js]
|
||||
export var a = 10;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js]
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
import * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
var x = nameSpaceBinding.a;
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user