-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Proposal for codefix commands #34787
Comments
This proposed TS API changes seem good to me. I don't see any issues implementing this on our side. We'll just need to figure out how best to surface the success / failure messages to users Let me know when the TS part lands in a nightly build so that I can try prototyping this |
If we put this in a nightly build, people will start seeing codefixes that don't work. Could you check out a branch instead? |
Sure, sounds good |
@mjbvz You can checkout and build the |
Thanks @andy-ms. I'll open a PR on our side shortly. A few quick notes: Looks like Also, I get this error when I try to run the command:
|
Here's the PR: #35002 |
@mjbvz I pushed a quick fix of those two issues -- changed the name from "action" to "command" and remembered to write to a file rather than to a directory. |
Ok, the fix looks good. I see the d.ts file being created now |
Any reason this couldn't land in nightly so I can experiment with it? Regular users won't see anything until we actually add something in TypeScript master that uses this. |
We're getting ready for release currently but I can check this in once we branch off for the September release. This code in its current state won't compile until we pick up a new *.d.ts file from TypeScript, but we can sprinkle in some |
Initial prototype to support commands on JS/TS quick fixes Part of microsoft#34787
* Prototype TS Codefix commands Initial prototype to support commands on JS/TS quick fixes Part of #34787 * use command for argument name * Update to use published api
This would enable microsoft/TypeScript#14423.
I am mostly describing changes to
protocol.ts
in the TypeScript repository here.@mjbvz @egamma @mhegazy we discussed this today.
1
The returned
CodeAction
in a code action request may include a list of commands.A code action may even have an empty
changes
list and consist of only a command.We could choose specify that
command
must an of commands, although I'm not sure if that's worth bothering with.2
If the code action is accepted, the editor must send the commands back to the language service to actually be carried out. This means needing a new request type, "applyCodeFixCommand". This looks like:
The contents of
command
will just be what was sent to the editor.(Typically this will include a "type" field so the language service can dispatch on the type of action.)
3
The language service should send a response when the action is complete.
I'm thinking we can just reuse the
message
field for error reporting and for a successful response. (Currently the field is documented to only be used ifsuccess
is false.) We could put that in the body, but then it seems redundant.The text was updated successfully, but these errors were encountered: