@@ -178,6 +178,11 @@ namespace ts {
178
178
179
179
const typeReferenceExtensions = [ ".d.ts" ] ;
180
180
181
+ function getEffectiveTypeRoots ( options : CompilerOptions , host : ModuleResolutionHost ) {
182
+ return options . typeRoots ||
183
+ defaultTypeRoots . map ( d => combinePaths ( options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) , d ) ) ;
184
+ }
185
+
181
186
/**
182
187
* @param {string | undefined } containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
183
188
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
@@ -192,8 +197,7 @@ namespace ts {
192
197
traceEnabled
193
198
} ;
194
199
195
- const typeRoots = options . typeRoots ||
196
- defaultTypeRoots . map ( d => combinePaths ( options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) , d ) ) ;
200
+ const typeRoots = getEffectiveTypeRoots ( options , host ) ;
197
201
if ( traceEnabled ) {
198
202
if ( containingFile === undefined ) {
199
203
if ( typeRoots === undefined ) {
@@ -1032,8 +1036,7 @@ namespace ts {
1032
1036
// Walk the primary type lookup locations
1033
1037
let result : string [ ] = [ ] ;
1034
1038
if ( host . directoryExists && host . getDirectories ) {
1035
- const typeRoots = options . typeRoots ||
1036
- defaultTypeRoots . map ( d => combinePaths ( options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) , d ) ) ;
1039
+ const typeRoots = getEffectiveTypeRoots ( options , host ) ;
1037
1040
for ( const root of typeRoots ) {
1038
1041
if ( host . directoryExists ( root ) ) {
1039
1042
result = result . concat ( host . getDirectories ( root ) ) ;
@@ -1208,7 +1211,7 @@ namespace ts {
1208
1211
( oldOptions . rootDir !== options . rootDir ) ||
1209
1212
( oldOptions . configFilePath !== options . configFilePath ) ||
1210
1213
( oldOptions . baseUrl !== options . baseUrl ) ||
1211
- ( oldOptions . typeRoots !== options . typeRoots ) ||
1214
+ ! arrayIsEqualTo ( oldOptions . typeRoots , oldOptions . typeRoots ) ||
1212
1215
! arrayIsEqualTo ( oldOptions . rootDirs , options . rootDirs ) ||
1213
1216
! mapIsEqualTo ( oldOptions . paths , options . paths ) ) {
1214
1217
return false ;
0 commit comments