"fix everything in this file" code action #29452
Labels
API
Relates to the public API for TypeScript
Domain: Quick Fixes
Editor-provided fixes, often called code actions.
Domain: TSServer
Issues related to the TSServer
In Discussion
Not yet reached consensus
Suggestion
An idea for TypeScript
VS Code is investigating an api for better support for fixing all fixable errors in a file with a single action. This action could also be triggered on save. You can find the current proposal here
Motivating use case
You change a file's extension from
ts
tojs
and start seeing lots of errors about converting your old jsdocs to real types. Thankfully you've enabled"editor.codeActionsOnSave": { "source.autoFix": true }
in VS Code and TypeScript has implemented this feature. So you just save the file and all your jsdocs are converted to types (along with fixing other trivial errors)Current VS Code proposal
The current VS Code proposal for this requires that extensions return a single source code action marked as
autoFix
. This action would contain all auto-fix edits for the file. We'd handle applying these edits on save.Proposal for TS
To implement this properly for TS, we likely need a new TS server api that would take a file and return a set of edits that fix all of the trivial errors within that file. Making this a single API call per file allows TS to properly handle overlapping fixes within the file. Candidates for what could be fixed automatically:
convert jsdocs to types
I see this feature as being especially helpful for JS -> TS. The initial implementation would only need to support fixes for a small set of diagnostics, which could be expanded in future releases.
/cc @DanielRosenwasser, @minestarks, @amcasey
The text was updated successfully, but these errors were encountered: