@@ -313,7 +313,7 @@ module ts {
313
313
}
314
314
let diagnostic : DiagnosticMessage ;
315
315
if ( hasExtension ( fileName ) ) {
316
- if ( ! options . allowNonTsExtensions && ! fileExtensionIs ( host . getCanonicalFileName ( fileName ) , ".ts" ) ) {
316
+ if ( ! options . allowNonTsExtensions && ! forEach ( supportedExtensions , extension => fileExtensionIs ( host . getCanonicalFileName ( fileName ) , extension ) ) ) {
317
317
diagnostic = Diagnostics . File_0_must_have_extension_ts_or_d_ts ;
318
318
}
319
319
else if ( ! findSourceFile ( fileName , isDefaultLib , refFile , refPos , refEnd ) ) {
@@ -327,7 +327,7 @@ module ts {
327
327
if ( options . allowNonTsExtensions && ! findSourceFile ( fileName , isDefaultLib , refFile , refPos , refEnd ) ) {
328
328
diagnostic = Diagnostics . File_0_not_found ;
329
329
}
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 ) ) ) {
331
331
diagnostic = Diagnostics . File_0_not_found ;
332
332
fileName += ".ts" ;
333
333
}
@@ -417,9 +417,10 @@ module ts {
417
417
let moduleNameText = ( < LiteralExpression > moduleNameExpr ) . text ;
418
418
if ( moduleNameText ) {
419
419
let searchPath = basePath ;
420
+ let searchName : string ;
420
421
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 ) ) ) {
423
424
break ;
424
425
}
425
426
let parentPath = getDirectoryPath ( searchPath ) ;
@@ -448,10 +449,7 @@ module ts {
448
449
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
449
450
// only through top - level external module names. Relative external module names are not permitted.
450
451
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 ) ) ;
455
453
}
456
454
}
457
455
} ) ;
0 commit comments