-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
chore(types): compatible with TS 5.8 #12973
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?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
@@ -113,7 +118,9 @@ export function queueJob(job: SchedulerJob): void { | |||
|
|||
function queueFlush() { | |||
if (!currentFlushPromise) { | |||
currentFlushPromise = resolvedPromise.then(flushJobs) | |||
currentFlushPromise = resolvedPromise.then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested that revert this change and the change of line 50.
tsc works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I just thought we can get rid of the type assertion, I can change it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
I added some type tests for |
WalkthroughAdds TypeScript type test for nextTick, updates nextTick overloads to include no-arg and promise-returning callback variants, and adjusts proxyRefs reactive-branch return type via cast. No runtime logic changes. Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
/ecosystem-ci run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/reactivity/src/ref.ts (1)
274-280
: Add a brief comment explaining why the cast is required.Preempt future “cleanup” regressions by documenting that TS 5.8 requires this assertion to make both branches assignable to the declared return type.
Apply:
export function proxyRefs<T extends object>( objectWithRefs: T, ): ShallowUnwrapRef<T> { return isReactive(objectWithRefs) - ? (objectWithRefs as ShallowUnwrapRef<T>) + // TS 5.8: granular checks for return branches require the reactive branch + // to be explicitly asserted to `ShallowUnwrapRef<T>`. + ? (objectWithRefs as ShallowUnwrapRef<T>) : new Proxy(objectWithRefs, shallowUnwrapHandlers) }packages-private/dts-test/scheduler.test-d.ts (1)
4-31
: Good coverage of overload resolution and Promise flattening.Consider adding a test that verifies
this
binding inference for the callback overload.Suggested addition:
describe('nextTick', async () => { + // `this` binding inference for callback overload + const ctx = { foo: 1 } + expectType<Promise<number>>( + nextTick.call(ctx, function () { + expectType<{ foo: number }>(this) + return 1 + }), + )packages/runtime-core/src/scheduler.ts (1)
65-67
: Avoid falsy-this
edge case in binding.
this ? fn.bind(this) : fn
skips binding whenthis
is falsy (e.g.,0
), losing the intended context. Calling via.call
avoids this.Apply:
- return fn ? p.then(this ? fn.bind(this) : fn) : p + return fn ? p.then(() => fn.call(this)) : p
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
packages-private/dts-test/scheduler.test-d.ts
(1 hunks)packages/reactivity/src/ref.ts
(1 hunks)packages/runtime-core/src/scheduler.ts
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/reactivity/src/ref.ts (2)
packages/runtime-core/src/index.ts (1)
ShallowUnwrapRef
(208-208)packages/reactivity/src/index.ts (1)
ShallowUnwrapRef
(19-19)
🔇 Additional comments (2)
packages/reactivity/src/ref.ts (1)
274-280
: TS 5.8 return-branch tightening: the cast is appropriate.The explicit cast on the reactive branch aligns both branches to
ShallowUnwrapRef<T>
under TS 5.8’s granular return-branch checks. Runtime semantics remain unchanged.packages/runtime-core/src/scheduler.ts (1)
56-67
: Overloads accurately modelnextTick
usages.The no-arg
Promise<void>
and generic callback overload returningPromise<R>
match real call sites and fix TS 5.8 branch-check issues.
📝 Ran ecosystem CI: Open
|
Ref: https://devblogs.microsoft.com/typescript/announcing-typescript-5-8/#granular-checks-for-branches-in-return-expressions
This PR didn't upgrade TypeScript, it only fixed the type errors that arose after the upgrade.
I couldn't find an elegant solution for
proxyRefs
, so I resorted to usingas any
😬Summary by CodeRabbit
New Features
Refactor
Tests