Skip to content

Commit

Permalink
(fix) prevent ts assertion error (#1962)
Browse files Browse the repository at this point in the history
#1956

Only add the file to the project if it has a projectRootPath, because else a ts.Assert error will be thrown when multiple inferred projects are tried to be merged.
  • Loading branch information
dummdidumm authored Mar 24, 2023
1 parent 98ac081 commit c272019
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/typescript-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ function init(modules: { typescript: typeof ts }): ts.server.PluginModule {
project.projectService.openFiles.set(scriptInfo.path, undefined);
}

project.addRoot(scriptInfo);
if ((project as any).projectRootPath) {
// Only add the file to the project if it has a projectRootPath, because else
// a ts.Assert error will be thrown when multiple inferred projects are tried
// to be merged.
project.addRoot(scriptInfo);
}
}

return { create, getExternalFiles, onConfigurationChanged };
Expand Down

0 comments on commit c272019

Please sign in to comment.