-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Idea: Migrate to TypeScript plugin #836
Comments
Also I've seen you use TS typeChecker, why don't you use TS AST API then and prefer babel then? Sorry, I might be missing something |
That sounds like a good idea. I haven't spent much time and energy on Abracadabra recently, but I will give this more thought during the weekend and come back to you. Thanks for the detailed suggestion @zardoy 👍 |
May be helpful: I just noticed that there is now an official way to retrieve the TS API used by VS Code (https://code.visualstudio.com/api/references/contribution-points#contributes.typescriptServerPlugins) |
Also useful, just realize you can send commands to the TS extension language of VS Code to do the changes, like @zardoy mentioned. Example: https://github.com/zardoy/typescript-vscode-plugins/blob/4afae28467c9a061ebb95ff4d12525adc7913018/src/sendCommand.ts#L41-L48 Resources:
|
This is continuation of #415 (comment) from @OliverJAsh
So basically I suggest to rewrite a few files to use TS ast instead of babel. Advantages:
typescript.format
settings (Move Statement Down
/Up
Always Add Semicolons #481)For example extract-use-callback would better infer type (I couldnt check current implementation as abracadabra always giving error
😅 I'm sorry, something went wrong: Failed to load parser '@typescript-eslint/parser' declared in 'CLIOptions': Cannot find module '@typescript-eslint/parser' Require stack: - /__placeholder__.js
)For example this is how I implemented Split declaration and initialization refactoring. And this code action still works on the web and with Volar (eg vue file or takeover mode).
On the other hand its known that TS refactorings has very limited functionality its not possible to build interactive code actions, they don't even support snippets, so I was using the following workaround: registering my own code action provider which sends custom requests to TS server, where I can return arbitrary data. For two-step code actions such as move to existing file just need to send such request twice. For example I have refactoring to convert array into object by selecting specific key (I can attach gif if needed, and by the way, do you like the idea of such refactoring?).
I've heard you have very limited time, so I'd happy to help you with some PRs, feel free to ask any kind of questions :)
The text was updated successfully, but these errors were encountered: