-
-
Notifications
You must be signed in to change notification settings - Fork 119
Update for TS7 #264
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
base: main
Are you sure you want to change the base?
Update for TS7 #264
Conversation
I am testing Typescript 7's JS support, which I've largely rewritten during the switch to Go. The new code processes tags by converting them into synthetic nodes just after parsing their host node. For unified, that means that `@template` tags can't be shared between multiple `@overload` tags like before. This PR also has to convert function declarations with `@type` on them to variables initialised with a function expression. TS7 doesn't currently support this feature on function declarations--but both unified and svelte use this feature a lot, so I think we'll need to add it before TS7's JS features are ready. At that point the shuffling of functions in the test files won't be needed anymore. In addition, microsoft/typescript-go#1444 makes it possible to have rest parameters in `@overload`, and is needed for this change to work in TS7, so it won't compile with the nightly until that PR is merged. Because TS7 is quite a way off, I don't know whether you'll want to take this PR. I created it to see how hard it would be to update popular JS code that uses TS for checking.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #264 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 1364 1364
=========================================
Hits 1364 1364 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I reverted the function->const move because I couldn't get it to compile in TS5 and I've decided to add whole-type annotated functions in TS7, so that change won't be needed. |
Hi again! Right, probably makes sense to have the If you are looking at userland code, you might as well also look at https://github.com/unifiedjs/unified/blob/main/script/fix-types.js 😉 It may be especially interesting because it also deals with rest parameters 🤔 |
Yes, I'd recommend this change everywhere. Shared template tags is a mistake that I've never fixed until TS7 gave me a chance to break JS backward compatibility. |
re fix-types.js: it looks like it had to fix up rest parameters with It sounds like I need to make sure that TS7 works with this type: |
Initial checklist
Description of changes
I am testing Typescript 7's JS support, which I've largely rewritten during the switch to Go. The new code processes tags by converting them into synthetic nodes just after parsing their host node. For unified, that means that
@template
tags can't be shared between multiple@overload
tags like before.This PR also has to convert function declarations with
@type
on them to variables initialised with a function expression. TS7 doesn't currently support this feature on function declarations--but both unified and svelte use this feature a lot, so I think we'll need to add it before TS7's JS features are ready. At that point the shuffling of functions won't be needed anymore and this PR will be very small.In addition, microsoft/typescript-go#1444 makes it possible to have rest parameters in
@overload
, and is needed for this change to work in TS7, so it won't compile with the nightly until that PR is merged.Edit: it will be available in the 2025-07-25 nightly.
Because TS7 is quite a way off, I don't know whether you'll want to take this PR. I created it to see how hard it would be to update popular JS code that uses TS for checking.