Typescript: Quick Fix support

Created on 6 Feb 2016  路  17Comments  路  Source: microsoft/TypeScript

It should b every cool if tsserver could support quickfix like https://github.com/TypeStrong/atom-typescript/blob/master/docs/quickfix.md

Quick fix could be returned when geterr is called like ESLint fix does.

API Quick Fixes Fixed Suggestion

Most helpful comment

Yes, this is completed with #10185

All 17 comments

thanks @angelozerr for filing this issue. We actually have Quick Fix support on our roadmap for 2.0; we just did not have an issue to track it, but now we do :)

but now we do :)

Thanks @mhegazy for your answer. I'm very enthousiasm with this cool feature.

This would be a great feature to add! As you can see nbts is waiting for it as well.

Hi,

I've worked a bit on @basarat 's implementation and tried to move it into the core.
In https://github.com/kisstkondoros/TypeScript/commit/0c414a57de86c1de1b4d8521ee1b53b64898641f one can find the initial implementation.

Any thoughts?

@kisstkondoros Thanks for that, it shows there is certainly demand for this feature. I see a couple of issues with integrating with VS (and possibly VSCode), e.g. you can't depend on the error message, since we ship in 14 languages. Can you take a look at my PR, #9304, and if you have suggestions to make the API more useful that's very much appreciated. Note, I didn't do any work yet to integrate this with tsserver yet, I need to discuss that with the VS Code team first.

@paulvanbrenk Yes I also thought it is not the best practice to get the context information from an error message 馃槃 perhaps extending the Diagnostic class with some context information could help for the more complicated use cases, e.g. adding missing methods / members to a class.
For me it seems that adding those could be done quite easily in core.ts.

Is this issue done by #10185 ?

Yes, this is completed with #10185

Great work! Adding imports will be really awesome.

BTW: Any plans to allow library-specific quick issues?

@olmobrutall Not sure what you mean by that.
The current API allows you to register a quickfix to an error... and we'll show all available fixes in the UI for that error. There is no planned work to limit fixes based on imports/libraries that are used in the project.

I mean an equivalent to C# Code Analyzers. Something like distribuiting codefixes together with .d.ts files.

The compiler will need to somehow load the codefix code at compile time.

Of course it requires TS compiler to do some eval() at some point, on code that may need to explore TS internal (inmutable?) data structures.

Ah, thanks.

Sorry for stupid question, how to enable/execute quick fix action inside vs code ? I see no light bulb. Do I have to use tslint ? thanks in advance

quick fixes don't work on Mac, works on Windows

Seems like a VSCode specific issue, @mjbvz any ideas?

@marcinnajder If you are on VSCode 1.10 (current insiders builds) and don't see the expected quick fixes, please open a bug: https://github.com/Microsoft/vscode/issues/new

works fine on VSCode 1.10, thanks for help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weswigham picture weswigham  路  3Comments

bgrieder picture bgrieder  路  3Comments

wmaurer picture wmaurer  路  3Comments

siddjain picture siddjain  路  3Comments

remojansen picture remojansen  路  3Comments