Skip to content

refactor(language-service): using the ls public API to check the acti… - #57165

Closed
ivanwonder wants to merge 1 commit into
angular:mainfrom
ivanwonder:use-ls-public-api-to-check-action-codes
Closed

ivanwonder wants to merge 1 commit into
angular:mainfrom
ivanwonder:use-ls-public-api-to-check-action-codes

Conversation

@ivanwonder

@ivanwonder ivanwonder commented Jul 28, 2024 •

Copy link
Copy Markdown
Contributor

…on codes

A public API called getSupportedCodeFixes is used to check if the compiler can fix the diagnostics. Remove the unnecessary export custom API.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove
pullapprove Bot requested a review from alxhub July 28, 2024 03:29
@angular-robot angular-robot Bot added the area: language-service Issues related to Angular's VS Code language service label Jul 28, 2024
@ngbot ngbot Bot added this to the Backlog milestone Jul 28, 2024
@devversion

devversion commented Jul 28, 2024 •

Copy link
Copy Markdown
Member

@ivanwonder what's the benefit of implementing this TS language service method if it's not used automatically? It seems like we also need some string conversions here and it's a little more ambiguous what the function returns (i.e. code fix ids? error codes as string? etc)

I don't see a downside to the custom method. It's unused right now, but exposed as it might be useful late. We've been also using customs for refactoring actions, for simpler integration

@ivanwonder

Copy link
Copy Markdown
Contributor Author

I think It's confusing to have two APIs(hasCodeFixesForErrorCode, getSupportedCodeFixes) to accomplish the same task.

it's a little more ambiguous what the function returns (i.e. code fix ids? error codes as string? etc)

But, this method is defined by the typescript, and return codes as string. It's better to stay consistent and rewrite the function defined by the typescript.

@devversion

Copy link
Copy Markdown
Member

I think It's confusing to have two APIs(hasCodeFixesForErrorCode, getSupportedCodeFixes) to accomplish the same task.

I don't think so, personally. There seem to be many methods that aren't necessarily updated. There doesn't seem to be a benefit, except for the downside of ambiguous w/ string conversions IMO— not feeling super strongly.

and return codes as string

That's the part that's not super clear IMO. Could also be a fix id for example. It's not well documented, if at all.

@ivanwonder

Copy link
Copy Markdown
Contributor Author

@atscott convert to draft. I will open it after we have a conclusion.

That's the part that's not super clear IMO. Could also be a fix id for example. It's not well documented, if at all.

Yes, there is no document for this method. For me, the GitHub issue and PR are the best ways to learn it.

From this PR, This method will be called by the built-in typescript extension if we need to support the developer to use the @angular/language-service as a typescript plugin(installed by adding an entry to the plugins list in their tsconfig.json file, not the vs code extension.)

@ivanwonder
ivanwonder marked this pull request as draft July 29, 2024 12:19
@devversion

Copy link
Copy Markdown
Member

From this microsoft/TypeScript#51769, This method will be called by the built-in typescript extension if we need to support the developer to use the @angular/language-service as a typescript plugin(installed by adding an entry to the plugins list in their tsconfig.json file, not the vs code extension.)

Is that something we support? cc. @atscott

@atscott

atscott commented Jul 29, 2024

Copy link
Copy Markdown
Contributor

support the developer to use the @angular/language-service as a typescript plugin(installed by adding an entry to the plugins list in their tsconfig.json file, not the vs code extension.)

Is that something we support? cc. @atscott

No, I don't believe so. There was some attempt at one point to consider this as a possibility but I don't believe it was ever attempted, tested, or supported.

@ivanwonder ivanwonder closed this Jul 30, 2024
@atscott

atscott commented Jul 30, 2024

Copy link
Copy Markdown
Contributor

@dylhunn @clydin Do you have any thoughts on this? You both have more experience than me with the ecosystem and using the language service in contexts other than the VSCode extension.

I didn't mean to say this shouldn’t be done, just that the “language service as a typescript plugin” was never attempted. It may still be valuable to keep this as a potential to explore, or at least keep to the current convention of using existing function names from the Typescript Language Service where possible.

@devversion

Copy link
Copy Markdown
Member

IMO probably not worth, given:

  • these methods by TypeScript are not documented at all / are ambiguous (see that we need to cast error codes to strings; might also be fix ids)
  • they are often more complicated than what we need. e.g. see the edit/refactoring methods.
  • they also lack things like e.g. reporting progress in the middle of computing edits (for e.g. signal migration)
  • we don't use the LS as a plugin apparently— and maybe it falls apart for other things already? e.g. the performance checks in the extension

@ivanwonder ivanwonder reopened this Jul 30, 2024
…on codes

A public API called [`getSupportedCodeFixes`][0] is used to check if the compiler
can fix the diagnostics. Remove the unnecessary export custom API.

[0]: https://github.com/microsoft/TypeScript/blob/6d3be985c82bead3b41348de76efec8110c677c5/src/services/types.ts#L697
@ivanwonder
ivanwonder force-pushed the use-ls-public-api-to-check-action-codes branch from c5fdb43 to c73901a Compare July 31, 2024 12:44
@JeanMeche

Copy link
Copy Markdown
Member

I'm doing some cleanup and close old drafts.

@JeanMeche JeanMeche closed this Mar 4, 2025
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: language-service Issues related to Angular's VS Code language service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants