Include type reference directives in symlink cache, wait until program is present to create it (#44259)

* Fix discovery of more pnpm symlinks

* Add some tests

* Never show pnpm paths in auto imports, even if there’s no other path

* Import statement completions can return none

* Fix tests

* Add failing test showing poor symlink cache reuse

* Fix test, fails for right reasons now

* Preserve cache built up during program creation, then fill in with program resolutions

* Remove obsolete comment

* Remove obsolete type assertion

* Revert fully filtering out ignored paths
This commit is contained in:
Andrew Branch
2021-06-08 12:06:55 -05:00
committed by GitHub
parent bf4642f089
commit 703c1bc69d
22 changed files with 197 additions and 43 deletions

View File

@@ -353,10 +353,15 @@ namespace ts.server {
/*@internal*/
getSymlinkCache(): SymlinkCache {
return this.symlinks || (this.symlinks = discoverProbableSymlinks(
this.program?.getSourceFiles() || emptyArray,
this.getCanonicalFileName,
this.getCurrentDirectory()));
if (!this.symlinks) {
this.symlinks = createSymlinkCache(this.getCurrentDirectory(), this.getCanonicalFileName);
}
if (this.program && !this.symlinks.hasProcessedResolutions()) {
this.symlinks.setSymlinksFromResolutions(
this.program.getSourceFiles(),
this.program.getResolvedTypeReferenceDirectives());
}
return this.symlinks;
}
// Method of LanguageServiceHost