mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
3f8d9d6ea6
In a composite/solution-style workspace (e.g. an Nx monorepo, where an app's tsconfig.json only contains project references), TypeScript can never resolve a config file for an HTML file, since HTML files are not listed in any referenced project. angular/vscode-ng-language-service#2165 worked around this in onDidOpenTextDocument by briefly opening the sibling TS file so the right project loads when a template is opened first. However, getDefaultProjectForScriptInfo - the recovery path used by getLSAndScriptInfo and onDidChangeTextDocument when a script info has no configured project - did not receive the same workaround. When an open template loses its project association (e.g. its component file is closed and the project graph updates), every subsequent request on the template fails with "No config file" and returns null indefinitely, until the user manually reopens the component file. Apply the same sibling-TS best effort in getDefaultProjectForScriptInfo, and additionally attach the template's script info to the configured project of its component when the config lookup still comes back empty (openClientFile does not repeat the config lookup for already-open files). Also skip the sibling lookup when the .ts file does not exist, so non-component HTML files (e.g. src/index.html) do not trigger an open/close and config search that cannot succeed. Fixes #69768