test(types): restore TypeScript 5.9 to CI matrix#2464
Merged
Conversation
TS 5.9 tightened conditional-return-type assignability, which surfaced five errors in two helper modules where generic returns relied on flow narrowing through user-defined type guards. TypeScript does not propagate value-side narrowing back into a generic conditional return type, so each site needed either overloads or a typed cast. - callProp: replaced the conditional return with function overloads so no cast is required in the body. - computeGoal: rewrote as guarded returns, each branch cast to T. - getDefaultProp: return type widened to T[P] | undefined to match actual behaviour; existing callers already handled undefined. - toArray: replaced as-any with as-Arrify on the result. Restored 5.9 to the test-types matrix. Verified clean on tsc --noEmit against 5.0, 5.4, 5.7, 5.9. Closes #2441
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeScript 5.9 tightened conditional-return-type assignability, which broke five generic helpers in the core/shared packages. Each return type was correct in intent but unprovable to the compiler because TS does not propagate value-side narrowing through user-defined type guards back into a generic conditional return type. Patched each site with the most honest option available and restored 5.9 to the
test-typesmatrix.Approach
Per site, picked the cleanest fix:
callProp— replaced the single conditional-return signature with function overloads so no cast is needed in the body.computeGoal— rewrote as guarded returns, each branch cast to the declared return typeT.getDefaultProp— widened the return type toT[P] | undefinedto match actual behaviour. Existing callers (SpringValue,Controller,hasDefaultProp) already handle undefined viais.und,=== true, or!==.toArray— replacedas anywithas Arrify<Exclude<T, void>>on the result.as anywas deliberately avoided —as <ReturnType>keeps the structural compatibility check the compiler can still perform.Verification
tsc --noEmitclean on TS 5.0, 5.4, 5.7, 5.9. Unit suite passes (217 tests).Closes #2441