Skip to content

Commit 6aa4e97

Browse files
committed
fix(41736): tsserver should not crash if external file does not exist
If a file does not exist, `projectService.getOrCreateScriptInfoNotOpenedByClient()` will return `undefined`, but tsserver does not handle this case. Fix #41736
1 parent 1bd8e38 commit 6aa4e97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/server/project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ namespace ts.server {
11881188
// by the host for files in the program when the program is retrieved above but
11891189
// the program doesn't contain external files so this must be done explicitly.
11901190
inserted => {
1191-
const scriptInfo = this.projectService.getOrCreateScriptInfoNotOpenedByClient(inserted, this.currentDirectory, this.directoryStructureHost)!;
1192-
scriptInfo.attachToProject(this);
1191+
const scriptInfo = this.projectService.getOrCreateScriptInfoNotOpenedByClient(inserted, this.currentDirectory, this.directoryStructureHost);
1192+
scriptInfo?.attachToProject(this);
11931193
},
11941194
removed => this.detachScriptInfoFromProject(removed)
11951195
);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy