@@ -359,15 +359,20 @@ namespace ts {
359359
360360 // Find the name of the module alias, if there is one
361361 const importAliasName = getLocalNameForExternalImport ( importNode , currentSourceFile ) ;
362- if ( includeNonAmdDependencies && importAliasName ) {
363- // Set emitFlags on the name of the classDeclaration
364- // This is so that when printer will not substitute the identifier
365- setEmitFlags ( importAliasName , EmitFlags . NoSubstitution ) ;
366- aliasedModuleNames . push ( externalModuleName ) ;
367- importAliasNames . push ( createParameter ( /*decorators*/ undefined , /*modifiers*/ undefined , /*dotDotDotToken*/ undefined , importAliasName ) ) ;
368- }
369- else {
370- unaliasedModuleNames . push ( externalModuleName ) ;
362+ // It is possible that externalModuleName is undefined if it is not string literal.
363+ // This can happen in the invalid import syntax.
364+ // E.g : "import * from alias from 'someLib';"
365+ if ( externalModuleName ) {
366+ if ( includeNonAmdDependencies && importAliasName ) {
367+ // Set emitFlags on the name of the classDeclaration
368+ // This is so that when printer will not substitute the identifier
369+ setEmitFlags ( importAliasName , EmitFlags . NoSubstitution ) ;
370+ aliasedModuleNames . push ( externalModuleName ) ;
371+ importAliasNames . push ( createParameter ( /*decorators*/ undefined , /*modifiers*/ undefined , /*dotDotDotToken*/ undefined , importAliasName ) ) ;
372+ }
373+ else {
374+ unaliasedModuleNames . push ( externalModuleName ) ;
375+ }
371376 }
372377 }
373378
0 commit comments