@@ -53,13 +53,13 @@ namespace ts {
5353 if ( getRootLength ( moduleName ) !== 0 || nameStartsWithDotSlashOrDotDotSlash ( moduleName ) ) {
5454 let failedLookupLocations : string [ ] = [ ] ;
5555 let candidate = normalizePath ( combinePaths ( containingDirectory , moduleName ) ) ;
56- let resolvedFileName = loadNodeModuleFromFile ( candidate , /* loadOnlyDts */ false , failedLookupLocations , host ) ;
56+ let resolvedFileName = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
5757
5858 if ( resolvedFileName ) {
5959 return { resolvedModule : { resolvedFileName } , failedLookupLocations } ;
6060 }
6161
62- resolvedFileName = loadNodeModuleFromDirectory ( candidate , /* loadOnlyDts */ false , failedLookupLocations , host ) ;
62+ resolvedFileName = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
6363 return resolvedFileName
6464 ? { resolvedModule : { resolvedFileName } , failedLookupLocations }
6565 : { resolvedModule : undefined , failedLookupLocations } ;
@@ -69,13 +69,8 @@ namespace ts {
6969 }
7070 }
7171
72- function loadNodeModuleFromFile ( candidate : string , loadOnlyDts : boolean , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73- if ( loadOnlyDts ) {
74- return tryLoad ( ".d.ts" ) ;
75- }
76- else {
77- return forEach ( supportedExtensions , tryLoad ) ;
78- }
72+ function loadNodeModuleFromFile ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73+ return forEach ( moduleFileExtensions , tryLoad ) ;
7974
8075 function tryLoad ( ext : string ) : string {
8176 let fileName = fileExtensionIs ( candidate , ext ) ? candidate : candidate + ext ;
@@ -89,7 +84,7 @@ namespace ts {
8984 }
9085 }
9186
92- function loadNodeModuleFromDirectory ( candidate : string , loadOnlyDts : boolean , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
87+ function loadNodeModuleFromDirectory ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
9388 let packageJsonPath = combinePaths ( candidate , "package.json" ) ;
9489 if ( host . fileExists ( packageJsonPath ) ) {
9590
@@ -105,7 +100,7 @@ namespace ts {
105100 }
106101
107102 if ( jsonContent . typings ) {
108- let result = loadNodeModuleFromFile ( normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , loadOnlyDts , failedLookupLocation , host ) ;
103+ let result = loadNodeModuleFromFile ( normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , failedLookupLocation , host ) ;
109104 if ( result ) {
110105 return result ;
111106 }
@@ -116,7 +111,7 @@ namespace ts {
116111 failedLookupLocation . push ( packageJsonPath ) ;
117112 }
118113
119- return loadNodeModuleFromFile ( combinePaths ( candidate , "index" ) , loadOnlyDts , failedLookupLocation , host ) ;
114+ return loadNodeModuleFromFile ( combinePaths ( candidate , "index" ) , failedLookupLocation , host ) ;
120115 }
121116
122117 function loadModuleFromNodeModules ( moduleName : string , directory : string , host : ModuleResolutionHost ) : ResolvedModuleWithFailedLookupLocations {
@@ -127,12 +122,12 @@ namespace ts {
127122 if ( baseName !== "node_modules" ) {
128123 let nodeModulesFolder = combinePaths ( directory , "node_modules" ) ;
129124 let candidate = normalizePath ( combinePaths ( nodeModulesFolder , moduleName ) ) ;
130- let result = loadNodeModuleFromFile ( candidate , /* loadOnlyDts */ true , failedLookupLocations , host ) ;
125+ let result = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
131126 if ( result ) {
132127 return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
133128 }
134129
135- result = loadNodeModuleFromDirectory ( candidate , /* loadOnlyDts */ true , failedLookupLocations , host ) ;
130+ result = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
136131 if ( result ) {
137132 return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
138133 }
@@ -862,8 +857,8 @@ namespace ts {
862857 const importedFile = findModuleSourceFile ( resolution . resolvedFileName , file . imports [ i ] ) ;
863858 if ( importedFile && resolution . isExternalLibraryImport ) {
864859 if ( ! isExternalModule ( importedFile ) ) {
865- let start = getTokenPosOfNode ( file . imports [ i ] , file )
866- fileProcessingDiagnostics . add ( createFileDiagnostic ( file , start , file . imports [ i ] . end - start , Diagnostics . Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition , importedFile . fileName ) ) ;
860+ let start = getTokenPosOfNode ( file . imports [ i ] , file )
861+ fileProcessingDiagnostics . add ( createFileDiagnostic ( file , start , file . imports [ i ] . end - start , Diagnostics . Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition , importedFile . fileName ) ) ;
867862 }
868863 else if ( ! fileExtensionIs ( importedFile . fileName , ".d.ts" ) ) {
869864 let start = getTokenPosOfNode ( file . imports [ i ] , file )
0 commit comments