@@ -178,6 +178,11 @@ namespace ts {
178178
179179 const typeReferenceExtensions = [ ".d.ts" ] ;
180180
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+
181186 /**
182187 * @param {string | undefined } containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
183188 * 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 {
192197 traceEnabled
193198 } ;
194199
195- const typeRoots = options . typeRoots ||
196- defaultTypeRoots . map ( d => combinePaths ( options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) , d ) ) ;
200+ const typeRoots = getEffectiveTypeRoots ( options , host ) ;
197201 if ( traceEnabled ) {
198202 if ( containingFile === undefined ) {
199203 if ( typeRoots === undefined ) {
@@ -1032,8 +1036,7 @@ namespace ts {
10321036 // Walk the primary type lookup locations
10331037 let result : string [ ] = [ ] ;
10341038 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 ) ;
10371040 for ( const root of typeRoots ) {
10381041 if ( host . directoryExists ( root ) ) {
10391042 result = result . concat ( host . getDirectories ( root ) ) ;
@@ -1208,7 +1211,7 @@ namespace ts {
12081211 ( oldOptions . rootDir !== options . rootDir ) ||
12091212 ( oldOptions . configFilePath !== options . configFilePath ) ||
12101213 ( oldOptions . baseUrl !== options . baseUrl ) ||
1211- ( oldOptions . typeRoots !== options . typeRoots ) ||
1214+ ! arrayIsEqualTo ( oldOptions . typeRoots , oldOptions . typeRoots ) ||
12121215 ! arrayIsEqualTo ( oldOptions . rootDirs , options . rootDirs ) ||
12131216 ! mapIsEqualTo ( oldOptions . paths , options . paths ) ) {
12141217 return false ;
0 commit comments