-
Notifications
You must be signed in to change notification settings - Fork 26.1k
fix(language-service): Add resource files as roots to their associate… #45601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
25da39a
to
d955fc4
Compare
d955fc4
to
bb5fc16
Compare
@alxhub We should probably walk through the behavior of TS Server together so I can show you what I'm observing and how I got to this solution. Let me know when you're available |
8417b02
to
2390215
Compare
2390215
to
c1e3c48
Compare
c1e3c48
to
9783f13
Compare
263fb33
to
db289ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…d projects When an external template is read, adds the template file to to the project which contains. This is necessary to keep the projects open when navigating away from HTML files. Since a `tsconfig` cannot express including non-TS files, we need another way to indicate the template files are considered part of the project. Note that this does not ensure that the project in question _directly_ contains the component file. That is, the project might just include the component file through the program rather than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important because the TypeScript language service/server prefers projects which _directly_ contain the TS file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can possibly be a different project used between the TS and HTML files. For example, in Nx projects, the referenced configs are `tsconfig.app.json` and `tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot effectively express `projectContainsInfoDirectly` for HTML files. We could consider also updating the language server implementation to attempt to select the project to use for the template file based on which project contains its component file directly, using either the internal `project.projectContainsInfoDirectly` or as a workaround, check `project.isRoot(componentTsFile)`. Finally, keeping the projects open is hugely important in the solution style config case like Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not `tsconfig.app.json`. However, if our extension does not also know to select `tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in keeping projects open when there is an HTML file open and (2) optionally attempt to do this _only_ for projects that we know the TS language service will prioritize in TS files (i.e., attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close) and prioritize that project for all requests. fixes angular/vscode-ng-language-service#1623 fixes angular/vscode-ng-language-service#876
db289ad
to
72368b8
Compare
merge assistance: Alex already approved |
You can preview 25da39a at https://pr45601-25da39a.ngbuilds.io/. |
This PR was merged into the repository by commit d48cfbc. |
…d projects (#45601) When an external template is read, adds the template file to to the project which contains. This is necessary to keep the projects open when navigating away from HTML files. Since a `tsconfig` cannot express including non-TS files, we need another way to indicate the template files are considered part of the project. Note that this does not ensure that the project in question _directly_ contains the component file. That is, the project might just include the component file through the program rather than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important because the TypeScript language service/server prefers projects which _directly_ contain the TS file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can possibly be a different project used between the TS and HTML files. For example, in Nx projects, the referenced configs are `tsconfig.app.json` and `tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot effectively express `projectContainsInfoDirectly` for HTML files. We could consider also updating the language server implementation to attempt to select the project to use for the template file based on which project contains its component file directly, using either the internal `project.projectContainsInfoDirectly` or as a workaround, check `project.isRoot(componentTsFile)`. Finally, keeping the projects open is hugely important in the solution style config case like Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not `tsconfig.app.json`. However, if our extension does not also know to select `tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in keeping projects open when there is an HTML file open and (2) optionally attempt to do this _only_ for projects that we know the TS language service will prioritize in TS files (i.e., attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close) and prioritize that project for all requests. fixes angular/vscode-ng-language-service#1623 fixes angular/vscode-ng-language-service#876 PR Close #45601
…d projects (#45601) When an external template is read, adds the template file to to the project which contains. This is necessary to keep the projects open when navigating away from HTML files. Since a `tsconfig` cannot express including non-TS files, we need another way to indicate the template files are considered part of the project. Note that this does not ensure that the project in question _directly_ contains the component file. That is, the project might just include the component file through the program rather than directly in the `include` glob of the `tsconfig`. This distinction is somewhat important because the TypeScript language service/server prefers projects which _directly_ contain the TS file (see `projectContainsInfoDirectly` in the TS codebase). What this means it that there can possibly be a different project used between the TS and HTML files. For example, in Nx projects, the referenced configs are `tsconfig.app.json` and `tsconfig.editor.json`. `tsconfig.app.json` comes first in the base `tsconfig.json` and contains the entry point of the app. `tsconfig.editor.json` contains the `**.ts` glob of all TS files. This means that `tsconfig.editor.json` will be preferred by the TS server for TS files but the `tsconfig.app.json` will be used for HTML files since it comes first and we cannot effectively express `projectContainsInfoDirectly` for HTML files. We could consider also updating the language server implementation to attempt to select the project to use for the template file based on which project contains its component file directly, using either the internal `project.projectContainsInfoDirectly` or as a workaround, check `project.isRoot(componentTsFile)`. Finally, keeping the projects open is hugely important in the solution style config case like Nx. When a TS file is opened, TypeScript will only retain `tsconfig.editor.json` and not `tsconfig.app.json`. However, if our extension does not also know to select `tsconfig.editor.json`, it will automatically select `tsconfig.app.json` since it is defined first in the `tsconfig.json` file. So we need to teach TS server that we are (1) interested in keeping projects open when there is an HTML file open and (2) optionally attempt to do this _only_ for projects that we know the TS language service will prioritize in TS files (i.e., attempt to only keep `tsconfig.editor.json` open and allow `tsconfig.app.json` to close) and prioritize that project for all requests. fixes angular/vscode-ng-language-service#1623 fixes angular/vscode-ng-language-service#876 PR Close #45601
…ssociated projects (angular#45601)" This reverts commit d48cfbc. This breaks the language service for templates on linux https://app.circleci.com/pipelines/github/angular/vscode-ng-language-service/3530/workflows/8ff8accd-6814-44c9-b810-db504d175a91/jobs/3458 Verified that this is a real failure locally
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fanimations/13.3.6/13.3.7) | | [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcommon/13.3.6/13.3.7) | | [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/13.3.6/13.3.7) | | [@angular/compiler-cli](https://github.com/angular/angular) | devDependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/13.3.6/13.3.7) | | [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcore/13.3.6/13.3.7) | | [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fforms/13.3.6/13.3.7) | | [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/13.3.6/13.3.7) | | [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/13.3.6/13.3.7) | --- ### Release Notes <details> <summary>angular/angular</summary> ### [`v13.3.7`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#​1337-2022-05-11) [Compare Source](angular/angular@13.3.6...13.3.7) ##### core | Commit | Type | Description | | -- | -- | -- | | [73bbee2c0d](angular/angular@73bbee2) | perf | allow `checkNoChanges` mode to be tree-shaken in production ([#​45936](angular/angular#45936)) | ##### language-service | Commit | Type | Description | | -- | -- | -- | | [5ca3bcf4f8](angular/angular@5ca3bcf) | fix | Add resource files as roots to their associated projects ([#​45601](angular/angular#45601)) | #### Special Thanks Andrew Kushnir, Andrew Scott, George Kalpakas, JayMartMedia, JoostK, Paul Gschwendtner, Ted.chang, Thomas Mair, Will 保哥, dario-piotrowicz, mgechev and ᚷᛁᛟᚱᚷᛁ ᛒᚨᛚᚨᚲᚻᚨᛞᛉᛖ <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1348 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…d projects
When an external template is read, adds the template file to to the project which contains.
This is necessary to keep the projects open when navigating away from HTML files.
Since a
tsconfig
cannot express including non-TS files,we need another way to indicate the template files are considered part of the project.
Note that this does not ensure that the project in question directly contains the component
file. That is, the project might just include the component file through the program rather
than directly in the
include
glob of thetsconfig
. This distinction is somewhat importantbecause the TypeScript language service/server prefers projects which directly contain the TS
file (see
projectContainsInfoDirectly
in the TS codebase). What this means it that there canpossibly be a different project used between the TS and HTML files.
For example, in Nx projects, the referenced configs are
tsconfig.app.json
andtsconfig.editor.json
.tsconfig.app.json
comes first in the basetsconfig.json
andcontains the entry point of the app.
tsconfig.editor.json
contains the**.ts
glob of all TSfiles. This means that
tsconfig.editor.json
will be preferred by the TS server for TS filesbut the
tsconfig.app.json
will be used for HTML files since it comes first and we cannoteffectively express
projectContainsInfoDirectly
for HTML files.We could consider also updating the language server implementation to attempt
to select the project to use for the template file based on which project
contains its component file directly, using either the internal
project.projectContainsInfoDirectly
or as a workaround, check
project.isRoot(componentTsFile)
.Finally, keeping the projects open is hugely important in the solution style config case like
Nx. When a TS file is opened, TypeScript will only retain
tsconfig.editor.json
and nottsconfig.app.json
. However, if our extension does not also know to selecttsconfig.editor.json
, it will automatically selecttsconfig.app.json
since it is definedfirst in the
tsconfig.json
file. So we need to teach TS server that we are (1) interested inkeeping projects open when there is an HTML file open and (2) optionally attempt to do this
only for projects that we know the TS language service will prioritize in TS files (i.e.,
attempt to only keep
tsconfig.editor.json
open and allowtsconfig.app.json
to close)and prioritize that project for all requests.
fixes angular/vscode-ng-language-service#1623
fixes angular/vscode-ng-language-service#876