ts-error-translator icon indicating copy to clipboard operation
ts-error-translator copied to clipboard

As a "Language Service Plugin" to have broad support for IDEs besides vscode

Open eddyw opened this issue 2 years ago • 9 comments

Hey 👋

So, just throwing random ideas here. Instead of a vscode extension or adding an additional package, this could be wrapped as a TypeScript Language Service Plugin.

Language Service Plugins allow to report additional errors such as from a linter and technically they should have access to original diagnostics so theoretically it'd be possible to add "translated" diagnostics along side original diagnostics.

Assuming this works, then user can simply add this to tsconfig:

{
    "compilerOptions": {
        "plugins": [{ "name": "ts-error-translator" }]
    }
}

So any IDE that uses TypeScript language service would be able to load the plugin and report errors in that IDE's native way for displaying/reporting errors/messages.


I haven't personally written a TS language service plugin before, I'm slightly familiar with the APIs thought which I learned for no reason lol. If there is interest in this I could try this out when I get some time.

eddyw avatar May 04 '22 09:05 eddyw

Yes, this makes sense - I don't think I'll be prioritising this myself because:

  1. It's kind of a 'power user' flow - most beginners don't know that TS plugins exist, or that they're an option. They can feel worried diving into tsconfig.json.
  2. I want to target beginners, who are much more likely to get excited about and download an IDE extension.

mattpocock avatar May 04 '22 09:05 mattpocock

I've written a simple plugin before and I think if there is a function to get the "better" error message from a diagnostic code / id / number, it should be pretty easy to write this plugin (just call the original and map over the results).

Where I think this would shine is in certain teams / big open-source repositories where beginners wouldn't add this plugin but more experienced users might and the beginners would benefit. They don't need to install anything, it will be set up for them. This could help convince people to use typescript over javascript.

entropitor avatar May 12 '22 20:05 entropitor

This doesn't change my above state opinion, but I'm happy to leave this issue open if anyone else wants to work on this.

mattpocock avatar May 13 '22 07:05 mattpocock

Anyone works on this or wants to? I want this in intellij

Jarrodsz avatar Jan 08 '23 01:01 Jarrodsz

https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin

Jarrodsz avatar Jan 08 '23 01:01 Jarrodsz

Anyone ever started on this?

Jarrodsz avatar Jan 08 '23 11:01 Jarrodsz

Anyone ever started working on this? Shame thrre is so little effort would love to look into this, get some people together on discord and build thid in an hour

Jarrodsz avatar Jan 08 '23 11:01 Jarrodsz

I am happy to give it a go. @mattpocock @Jarrodsz

ivan-demchenko avatar Feb 06 '23 07:02 ivan-demchenko

I am happy to give it a go. @mattpocock @Jarrodsz

Would love to help. its probably not overcomplicated. There is already a prisma extension for intellij

Jarrodsz avatar Feb 06 '23 17:02 Jarrodsz