@@ -46,7 +46,7 @@ func processAllProgramFiles(
46
46
compilerOptions : compilerOptions ,
47
47
resolver : resolver ,
48
48
tasksByFileName : make (map [string ]* parseTask ),
49
- defaultLibraryPath : host .DefaultLibraryPath (),
49
+ defaultLibraryPath : tspath . GetNormalizedAbsolutePath ( host .DefaultLibraryPath (), host . GetCurrentDirectory () ),
50
50
comparePathsOptions : tspath.ComparePathsOptions {
51
51
UseCaseSensitiveFileNames : host .FS ().UseCaseSensitiveFileNames (),
52
52
CurrentDirectory : host .GetCurrentDirectory (),
@@ -152,8 +152,13 @@ func (p *fileLoader) sortLibs(libFiles []*ast.SourceFile) {
152
152
}
153
153
154
154
func (p * fileLoader ) getDefaultLibFilePriority (a * ast.SourceFile ) int {
155
- if tspath .ContainsPath (p .defaultLibraryPath , a .FileName (), p .comparePathsOptions ) {
156
- basename := tspath .GetBaseFileName (a .FileName ())
155
+ // defaultLibraryPath and a.FileName() are absolute and normalized; a prefix check should suffice.
156
+ defaultLibraryPath := tspath .RemoveTrailingDirectorySeparator (p .defaultLibraryPath )
157
+ aFileName := a .FileName ()
158
+
159
+ if strings .HasPrefix (aFileName , defaultLibraryPath ) && len (aFileName ) > len (defaultLibraryPath ) && aFileName [len (defaultLibraryPath )] == tspath .DirectorySeparator {
160
+ // avoid tspath.GetBaseFileName; we know these paths are already absolute and normalized.
161
+ basename := aFileName [strings .LastIndexByte (aFileName , tspath .DirectorySeparator )+ 1 :]
157
162
if basename == "lib.d.ts" || basename == "lib.es6.d.ts" {
158
163
return 0
159
164
}
0 commit comments