You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the new 5.2 version the children property on type checking returns an error
Type error: Type 'T[K]' does not satisfy the constraint '{}'.
Type 'T[keyof T]' is not assignable to type '{}'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '{}'.
Type 'T[string]' is not assignable to type '{}'.
on line children?: T[K] extends Array<infer U> ? ItemDef<U extends {} ? U : never, keyof U> : ItemDef<T[K], keyof T[K]>;
while in the previous version the type check was fine
π Expected behavior
Not sure if it was an error on previous version (5.1.6) or it's a regression.
If a regression to work fine
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
This code didn't typecheck with 5.0 and the fact that it did typecheck ok with 5.1 was a bug. This works as intended.
You need to find a way to add the appropriate constraint to T[K] there. I see that you are already doing this ItemDef<U extends {} ? U : never, keyof U> in the array-related branch of this conditional type. A similar thing would do the trick in the branch that doesn't typecheck today: ItemDef<T[K] extends {} ? T[K] : never, keyof T[K]>. That said, I'd probably try to improve the T's constraint on your place.
π Search Terms
type checking on extending generics
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
In the new 5.2 version the
children
property on type checking returns an erroron line
children?: T[K] extends Array<infer U> ? ItemDef<U extends {} ? U : never, keyof U> : ItemDef<T[K], keyof T[K]>;
while in the previous version the type check was fine
π Expected behavior
Not sure if it was an error on previous version (5.1.6) or it's a regression.
If a regression to work fine
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: