-
Notifications
You must be signed in to change notification settings - Fork 13.3k
script info for external project could be undefined #41736
Description
Angular language service (View Engine version) uses getExternalFiles() to add html templates to the ConfiguredProject. For each file, tsserver will get or create a script info, and attach it to the project.
However, if the file does not exist on disk, no script info will be created, but tsserver does not handle this case.
Specifically,scriptInfo returned by this.projectService.getOrCreateScriptInfoNotOpenedByClient() could be undefined.
TypeScript Version: 4.2.0-dev.20201130
Search Terms:
external file, script info, tsserver
Code
Note the unsafe non-null assertion at the end of line 1191:
TypeScript/src/server/project.ts
Lines 1190 to 1193 in 23b3eb6
| inserted => { | |
| const scriptInfo = this.projectService.getOrCreateScriptInfoNotOpenedByClient(inserted, this.currentDirectory, this.directoryStructureHost)!; | |
| scriptInfo.attachToProject(this); | |
| }, |
Expected behavior:
tsserver does not crash if script info for external file could not be created.
Actual behavior:
tsserver crashes when script info for external file could not be created.
Related Issues:
angular/vscode-ng-language-service#1001