@@ -53,13 +53,13 @@ namespace ts {
5353 if ( getRootLength ( moduleName ) !== 0 || nameStartsWithDotSlashOrDotDotSlash ( moduleName ) ) {
5454 const failedLookupLocations : string [ ] = [ ] ;
5555 const candidate = normalizePath ( combinePaths ( containingDirectory , moduleName ) ) ;
56- let resolvedFileName = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
56+ let resolvedFileName = loadNodeModuleFromFile ( supportedJsExtensions , candidate , failedLookupLocations , host ) ;
5757
5858 if ( resolvedFileName ) {
5959 return { resolvedModule : { resolvedFileName } , failedLookupLocations } ;
6060 }
6161
62- resolvedFileName = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
62+ resolvedFileName = loadNodeModuleFromDirectory ( supportedJsExtensions , candidate , failedLookupLocations , host ) ;
6363 return resolvedFileName
6464 ? { resolvedModule : { resolvedFileName } , failedLookupLocations }
6565 : { resolvedModule : undefined , failedLookupLocations } ;
@@ -69,8 +69,8 @@ namespace ts {
6969 }
7070 }
7171
72- function loadNodeModuleFromFile ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73- return forEach ( supportedExtensions , tryLoad ) ;
72+ function loadNodeModuleFromFile ( extensions : string [ ] , candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73+ return forEach ( extensions , tryLoad ) ;
7474
7575 function tryLoad ( ext : string ) : string {
7676 const fileName = fileExtensionIs ( candidate , ext ) ? candidate : candidate + ext ;
@@ -84,7 +84,7 @@ namespace ts {
8484 }
8585 }
8686
87- function loadNodeModuleFromDirectory ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
87+ function loadNodeModuleFromDirectory ( extensions : string [ ] , candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
8888 const packageJsonPath = combinePaths ( candidate , "package.json" ) ;
8989 if ( host . fileExists ( packageJsonPath ) ) {
9090
@@ -100,7 +100,7 @@ namespace ts {
100100 }
101101
102102 if ( jsonContent . typings ) {
103- const result = loadNodeModuleFromFile ( normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , failedLookupLocation , host ) ;
103+ const result = loadNodeModuleFromFile ( extensions , normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , failedLookupLocation , host ) ;
104104 if ( result ) {
105105 return result ;
106106 }
@@ -111,7 +111,7 @@ namespace ts {
111111 failedLookupLocation . push ( packageJsonPath ) ;
112112 }
113113
114- return loadNodeModuleFromFile ( combinePaths ( candidate , "index" ) , failedLookupLocation , host ) ;
114+ return loadNodeModuleFromFile ( extensions , combinePaths ( candidate , "index" ) , failedLookupLocation , host ) ;
115115 }
116116
117117 function loadModuleFromNodeModules ( moduleName : string , directory : string , host : ModuleResolutionHost ) : ResolvedModuleWithFailedLookupLocations {
@@ -122,12 +122,12 @@ namespace ts {
122122 if ( baseName !== "node_modules" ) {
123123 const nodeModulesFolder = combinePaths ( directory , "node_modules" ) ;
124124 const candidate = normalizePath ( combinePaths ( nodeModulesFolder , moduleName ) ) ;
125- let result = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
125+ let result = loadNodeModuleFromFile ( supportedExtensions , candidate , failedLookupLocations , host ) ;
126126 if ( result ) {
127127 return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
128128 }
129129
130- result = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
130+ result = loadNodeModuleFromDirectory ( supportedExtensions , candidate , failedLookupLocations , host ) ;
131131 if ( result ) {
132132 return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
133133 }
@@ -162,7 +162,7 @@ namespace ts {
162162 const failedLookupLocations : string [ ] = [ ] ;
163163
164164 let referencedSourceFile : string ;
165- let extensions = compilerOptions . allowNonTsExtensions ? supportedJsExtensions : supportedExtensions ;
165+ const extensions = compilerOptions . allowNonTsExtensions ? supportedJsExtensions : supportedExtensions ;
166166 while ( true ) {
167167 searchName = normalizePath ( combinePaths ( searchPath , moduleName ) ) ;
168168 referencedSourceFile = forEach ( extensions , extension => {
@@ -689,7 +689,7 @@ namespace ts {
689689 return ;
690690 }
691691
692- let isJavaScriptFile = isSourceFileJavaScript ( file ) ;
692+ const isJavaScriptFile = isSourceFileJavaScript ( file ) ;
693693
694694 let imports : LiteralExpression [ ] ;
695695 for ( const node of file . statements ) {
0 commit comments