@@ -313,7 +313,7 @@ module ts {
313313 }
314314 let diagnostic : DiagnosticMessage ;
315315 if ( hasExtension ( fileName ) ) {
316- if ( ! options . allowNonTsExtensions && ! fileExtensionIs ( host . getCanonicalFileName ( fileName ) , ".ts" ) ) {
316+ if ( ! options . allowNonTsExtensions && ! forEach ( supportedExtensions , extension => fileExtensionIs ( host . getCanonicalFileName ( fileName ) , extension ) ) ) {
317317 diagnostic = Diagnostics . File_0_must_have_extension_ts_or_d_ts ;
318318 }
319319 else if ( ! findSourceFile ( fileName , isDefaultLib , refFile , refPos , refEnd ) ) {
@@ -327,7 +327,7 @@ module ts {
327327 if ( options . allowNonTsExtensions && ! findSourceFile ( fileName , isDefaultLib , refFile , refPos , refEnd ) ) {
328328 diagnostic = Diagnostics . File_0_not_found ;
329329 }
330- else if ( ! findSourceFile ( fileName + ".ts" , isDefaultLib , refFile , refPos , refEnd ) && ! findSourceFile ( fileName + ".d.ts" , isDefaultLib , refFile , refPos , refEnd ) ) {
330+ else if ( ! forEach ( supportedExtensions , extension => findSourceFile ( fileName + extension , isDefaultLib , refFile , refPos , refEnd ) ) ) {
331331 diagnostic = Diagnostics . File_0_not_found ;
332332 fileName += ".ts" ;
333333 }
@@ -417,9 +417,10 @@ module ts {
417417 let moduleNameText = ( < LiteralExpression > moduleNameExpr ) . text ;
418418 if ( moduleNameText ) {
419419 let searchPath = basePath ;
420+ let searchName : string ;
420421 while ( true ) {
421- let searchName = normalizePath ( combinePaths ( searchPath , moduleNameText ) ) ;
422- if ( findModuleSourceFile ( searchName + ".ts" , moduleNameExpr ) || findModuleSourceFile ( searchName + ".d.ts" , moduleNameExpr ) ) {
422+ searchName = normalizePath ( combinePaths ( searchPath , moduleNameText ) ) ;
423+ if ( forEach ( supportedExtensions , extension => findModuleSourceFile ( searchName + extension , moduleNameExpr ) ) ) {
423424 break ;
424425 }
425426 let parentPath = getDirectoryPath ( searchPath ) ;
@@ -448,10 +449,7 @@ module ts {
448449 // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
449450 // only through top - level external module names. Relative external module names are not permitted.
450451 let searchName = normalizePath ( combinePaths ( basePath , moduleName ) ) ;
451- let tsFile = findModuleSourceFile ( searchName + ".ts" , nameLiteral ) ;
452- if ( ! tsFile ) {
453- findModuleSourceFile ( searchName + ".d.ts" , nameLiteral ) ;
454- }
452+ forEach ( supportedExtensions , extension => findModuleSourceFile ( searchName + extension , nameLiteral ) ) ;
455453 }
456454 }
457455 } ) ;
0 commit comments