@@ -5004,6 +5004,10 @@ module ts {
5004
5004
}
5005
5005
}
5006
5006
5007
+ function isDefaultImport ( node : ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration ) {
5008
+ return node . kind === SyntaxKind . ImportDeclaration && ( < ImportDeclaration > node ) . importClause && ! ! ( < ImportDeclaration > node ) . importClause . name ;
5009
+ }
5010
+
5007
5011
function emitExportImportAssignments ( node : Node ) {
5008
5012
if ( isAliasSymbolDeclaration ( node ) && resolver . isValueAliasDeclaration ( node ) ) {
5009
5013
emitExportMemberAssignments ( < Identifier > ( < Declaration > node ) . name ) ;
@@ -5018,8 +5022,7 @@ module ts {
5018
5022
if ( compilerOptions . module !== ModuleKind . AMD ) {
5019
5023
emitLeadingComments ( node ) ;
5020
5024
emitStart ( node ) ;
5021
- let isDefaultImport = node . kind === SyntaxKind . ImportDeclaration && ( < ImportDeclaration > node ) . importClause && ! ! ( < ImportDeclaration > node ) . importClause . name ;
5022
- if ( namespaceDeclaration && ! isDefaultImport ) {
5025
+ if ( namespaceDeclaration && ! isDefaultImport ( node ) ) {
5023
5026
// import x = require("foo")
5024
5027
// import * as x from "foo"
5025
5028
if ( ! isExportedImport ) write ( "var " ) ;
@@ -5040,7 +5043,7 @@ module ts {
5040
5043
}
5041
5044
}
5042
5045
emitRequire ( getExternalModuleName ( node ) ) ;
5043
- if ( namespaceDeclaration && isDefaultImport ) {
5046
+ if ( namespaceDeclaration && isDefaultImport ( node ) ) {
5044
5047
// import d, * as x from "foo"
5045
5048
write ( ", " ) ;
5046
5049
emitModuleMemberName ( namespaceDeclaration ) ;
@@ -5059,6 +5062,14 @@ module ts {
5059
5062
emit ( namespaceDeclaration . name ) ;
5060
5063
write ( ";" ) ;
5061
5064
}
5065
+ else if ( namespaceDeclaration && isDefaultImport ( node ) ) {
5066
+ // import d, * as x from "foo"
5067
+ write ( "var " ) ;
5068
+ emitModuleMemberName ( namespaceDeclaration ) ;
5069
+ write ( " = " ) ;
5070
+ write ( resolver . getGeneratedNameForNode ( < ImportDeclaration > node ) ) ;
5071
+ write ( ";" ) ;
5072
+ }
5062
5073
emitExportImportAssignments ( node ) ;
5063
5074
}
5064
5075
}
@@ -5249,7 +5260,7 @@ module ts {
5249
5260
for ( let importNode of externalImports ) {
5250
5261
write ( ", " ) ;
5251
5262
let namespaceDeclaration = getNamespaceDeclarationNode ( importNode ) ;
5252
- if ( namespaceDeclaration ) {
5263
+ if ( namespaceDeclaration && ! isDefaultImport ( importNode ) ) {
5253
5264
emit ( namespaceDeclaration . name ) ;
5254
5265
}
5255
5266
else {
0 commit comments