@@ -143,7 +143,10 @@ func processAllProgramFiles(
143
143
144
144
filesByPath := make (map [tspath.Path ]* ast.SourceFile , totalFileCount )
145
145
loader .includeProcessor .fileIncludeReasons = make (map [tspath.Path ][]* fileIncludeReason , totalFileCount )
146
- outputFileToProjectReferenceSource := make (map [tspath.Path ]string , totalFileCount )
146
+ var outputFileToProjectReferenceSource map [tspath.Path ]string
147
+ if ! opts .canUseProjectReferenceSource () {
148
+ outputFileToProjectReferenceSource = make (map [tspath.Path ]string , totalFileCount )
149
+ }
147
150
resolvedModules := make (map [tspath.Path ]module.ModeAwareCache [* module.ResolvedModule ], totalFileCount + 1 )
148
151
typeResolutionsInFile := make (map [tspath.Path ]module.ModeAwareCache [* module.ResolvedTypeReferenceDirective ], totalFileCount )
149
152
sourceFileMetaDatas := make (map [tspath.Path ]ast.SourceFileMetaData , totalFileCount )
@@ -454,9 +457,9 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) {
454
457
typeResolutionsInFile := make (module.ModeAwareCache [* module.ResolvedTypeReferenceDirective ], len (file .TypeReferenceDirectives ))
455
458
var typeResolutionsTrace []string
456
459
for index , ref := range file .TypeReferenceDirectives {
457
- redirect := p .projectReferenceFileMapper .getRedirectForResolution (file )
460
+ redirect , fileName := p .projectReferenceFileMapper .getRedirectForResolution (file )
458
461
resolutionMode := getModeForTypeReferenceDirectiveInFile (ref , file , meta , module .GetCompilerOptionsWithRedirect (p .opts .Config .CompilerOptions (), redirect ))
459
- resolved , trace := p .resolver .ResolveTypeReferenceDirective (ref .FileName , file . FileName () , resolutionMode , redirect )
462
+ resolved , trace := p .resolver .ResolveTypeReferenceDirective (ref .FileName , fileName , resolutionMode , redirect )
460
463
typeResolutionsInFile [module.ModeAwareCacheKey {Name : ref .FileName , Mode : resolutionMode }] = resolved
461
464
includeReason := & fileIncludeReason {
462
465
kind : fileIncludeKindTypeReferenceDirective ,
@@ -498,7 +501,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
498
501
isJavaScriptFile := ast .IsSourceFileJS (file )
499
502
isExternalModuleFile := ast .IsExternalModule (file )
500
503
501
- redirect := p .projectReferenceFileMapper .getRedirectForResolution (file )
504
+ redirect , fileName := p .projectReferenceFileMapper .getRedirectForResolution (file )
502
505
optionsForFile := module .GetCompilerOptionsWithRedirect (p .opts .Config .CompilerOptions (), redirect )
503
506
if isJavaScriptFile || (! file .IsDeclarationFile && (optionsForFile .GetIsolatedModules () || isExternalModuleFile )) {
504
507
if optionsForFile .ImportHelpers .IsTrue () {
@@ -539,7 +542,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
539
542
}
540
543
541
544
mode := getModeForUsageLocation (file .FileName (), meta , entry , optionsForFile )
542
- resolvedModule , trace := p .resolver .ResolveModuleName (moduleName , file . FileName () , mode , redirect )
545
+ resolvedModule , trace := p .resolver .ResolveModuleName (moduleName , fileName , mode , redirect )
543
546
resolutionsInFile [module.ModeAwareCacheKey {Name : moduleName , Mode : mode }] = resolvedModule
544
547
resolutionsTrace = append (resolutionsTrace , trace ... )
545
548
@@ -550,7 +553,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) {
550
553
resolvedFileName := resolvedModule .ResolvedFileName
551
554
isFromNodeModulesSearch := resolvedModule .IsExternalLibraryImport
552
555
// Don't treat redirected files as JS files.
553
- isJsFile := ! tspath .FileExtensionIsOneOf (resolvedFileName , tspath .SupportedTSExtensionsWithJsonFlat ) && p .projectReferenceFileMapper .getRedirectForResolution (ast .NewHasFileName (resolvedFileName , p .toPath (resolvedFileName ))) == nil
556
+ isJsFile := ! tspath .FileExtensionIsOneOf (resolvedFileName , tspath .SupportedTSExtensionsWithJsonFlat ) && p .projectReferenceFileMapper .getRedirectParsedCommandLineForResolution (ast .NewHasFileName (resolvedFileName , p .toPath (resolvedFileName ))) == nil
554
557
isJsFileFromNodeModules := isFromNodeModulesSearch && isJsFile && strings .Contains (resolvedFileName , "/node_modules/" )
555
558
556
559
// add file to program only if:
@@ -610,19 +613,19 @@ func (p *fileLoader) pathForLibFile(name string) *LibFile {
610
613
611
614
path := tspath .CombinePaths (p .defaultLibraryPath , name )
612
615
replaced := false
613
- if p .opts .Config .CompilerOptions ().LibReplacement .IsTrue () {
616
+ if p .opts .Config .CompilerOptions ().LibReplacement .IsTrue () && name != "lib.d.ts" {
614
617
libraryName := getLibraryNameFromLibFileName (name )
615
618
resolveFrom := getInferredLibraryNameResolveFrom (p .opts .Config .CompilerOptions (), p .opts .Host .GetCurrentDirectory (), name )
616
619
resolution , trace := p .resolver .ResolveModuleName (libraryName , resolveFrom , core .ModuleKindCommonJS , nil )
617
620
if resolution .IsResolved () {
618
621
path = resolution .ResolvedFileName
619
622
replaced = true
620
- p .pathForLibFileResolutions .LoadOrStore (p .toPath (resolveFrom ), & libResolution {
621
- libraryName : libraryName ,
622
- resolution : resolution ,
623
- trace : trace ,
624
- })
625
623
}
624
+ p .pathForLibFileResolutions .LoadOrStore (p .toPath (resolveFrom ), & libResolution {
625
+ libraryName : libraryName ,
626
+ resolution : resolution ,
627
+ trace : trace ,
628
+ })
626
629
}
627
630
628
631
libPath , _ := p .pathForLibFileCache .LoadOrStore (name , & LibFile {name , path , replaced })
0 commit comments