-
Notifications
You must be signed in to change notification settings - Fork 27k
Language service fixes #58719
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
Language service fixes #58719
Conversation
Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within `.ts` files. These changes make the `templateInfo` nullable and leave the early exit up to the individual fixes.
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.
| for (const action of codeActions) { | ||
| const actionChanges = action.changes.flatMap((change) => { | ||
| return change.textChanges.map((tc) => { | ||
| const oldText = collapse(fileContents.slice(tc.span.start, tc.span.start + spawn.length)); |
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.
Note the typo here was spawn.length instead of tc.span.length which meant that the assertion was always incorrect. I've fixed it plus a handful of tests that weren't asserting properly.
clydin
left a comment
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.
LGTM.
As followup, would it be useful to have some sort of requiresTemplateInfo boolean on the code fix action definition? As we increase the amount of code fixes, this would allow bypassing the getCodeActions call completely instead of adding null checks to each action. And it avoids the empty array creation plus spread/push for each.
|
This PR was merged into the repository by commit dcd27d7. The changes were merged into the following branches: main, 19.0.x |
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases. PR Close #58719
Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within `.ts` files. These changes make the `templateInfo` nullable and leave the early exit up to the individual fixes. PR Close #58719
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases. PR Close #58719
|
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. |
Includes the following fixes for the language service:
fix(language-service): allow fixes to run without template info
Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within
.tsfiles. These changes make thetemplateInfonullable and leave the early exit up to the individual fixes.fix(language-service): add fix for individual unused imports
Fixes that
getCodeActionswasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.