-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
API migration help for TypeScript 5.0 #52847
Comments
TS 5.0 also adds support for This seems pretty similar to what you're trying to do in your plugin, in that one can define a |
Thanks @jakebailey, I missed that Do you know who might be able to help with information around proxying other methods needed to read/process non-TS files? Perhaps a better alternative to using the now immutable For context, this plugin has around 200k+ weekly downloads, which I think (from a quick search) makes it one of the most popular language service plugins. It allows users to have type information from CSS (including Less, Sass, etc) without needing to watch and generate DTS files for those files in a separate process. |
@rbuckton has suggested that you could provide I'm planning on trying to go through as many plugins and patchers as possible to get a handle on which APIs people are trying to patch. I was hoping that the lack of feedback regarding this meant that it wasn't so widespread (this change happened circa November 2022), but, it seems like people are coming out of the woodwork now that the RC is approaching (which is unfortunate given a "fix" for this on the TS side is likely to be nontrivial). |
I've been working on that collected "ts patchers" list and stumbled upon Vue's LS plugin; they appear to proxy the host to provide similar functionality, so I believe that it's possible to do something like you already do within the current API: |
Sorry i missed this notification yesterday.
|
Thanks so much for all of the detail @jakebailey, and for the additional info @sheetalkamat. This is an unsponsored project, so I'll take a look at migrating to these APIs over the weekend! |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community. |
Thanks again for the help on this issue. I managed to get it working this weekend, and feeling very relieved! |
Glad you got it working. I left some comments on the PR which you may want to look at; in general, plugins should not import |
Sorry for the disturbance, I am the current primary maintainer of Vetur. Vetur now relies on If we want to change to the method mentioned above, we need to switch to a text-based approach combined with sourcemaps, which would be equivalent to rewriting the entire project. I would like to confirm if there are any similar hackable methods available? Otherwise, Vetur might have to give up on continuing support for TypeScript 5 and beyond. |
I am assuming you're referring to: https://github.com/vuejs/vetur/blob/96aaa707f8ca629f0883c57a47adb0e58995936d/server/src/services/typescriptService/preprocess.ts If I'm reading this correctly, you're calling the original In which case, can you just do the same thing but skip the final re-parse step and return source in Though, I'm a bit confused; I thought vetur was deprecated in favor of volar, which I think is working with TS 5.0? |
The main logic is in this line: Volar is the new official Vue extension, but it mainly focuses on Vue 3 projects; Vetur now focuses on supporting older Vue 2 projects, with limited support for Vue 3 and only providing basic maintenance, without adding new features. |
Suggestion
🔍 Search Terms
createLanguageServiceSourceFile
✅ Viability Checklist
My suggestion meets these guidelines:
⭐ Suggestion
Background
I'm currently trying to get my TypeScript plugin (
typescript-plugin-css-modules
) ready for TypeScript 5.0.This plugin adds autocompletion and go to definition support for CSS by generating virtual DTS files.
When running in TypeScript 5.0, I'm hitting this issue:
As I understand it, this is because of this TS 5.0 breaking change:
Source: https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes#typescript-50
What would help
I understand that the original design of this plugin may not be ideal, but I'd like to get this working in TypeScript 5.0.
I can see that proxying the
LanguageService
will help with most functions, but some of the methods I've been wrapping are not available on theLanguageService
- namelycreateLanguageServiceSourceFile
andupdateLanguageServiceSourceFile
.The offending lines are here:
As someone that isn't an expert in TS plugins, I'd love a migration guide or an example of how to migrate implementations like this.
📃 Motivating Example
N/A
💻 Use Cases
N/A
The text was updated successfully, but these errors were encountered: