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
The issue is that following #56515 we perform constraint reduction on intersection types T & P or P & T, where T is a type parameter or indexed access type and P is a primitive type, the object type, or {}, reducing the intersection type to just T when the constraint of T fully encompasses P. For example, for a T extends string, the intersection T & string is reduced to just T. In the repro, we attempt to reduce the intersection string & {...}[keyof T], but resolving the constraint of {...}[keyof T] causes a circularity. It's unfortunate, but the price we have to pay to get the benefits of the feature.
I'd suggest rewriting the BooleanPaths type to this simpler formulation:
typeBooleanPaths<T,KextendskeyofT=keyofT>=Kextendsstring ?
T[K]extendsboolean ? K :
T[K]extendsobject ? `${K}.${BooleanPaths<T[K]>}` :
never :
never;
No circularity and handles both object and tuple types.
π Search Terms
Type alias circularly references itself (5.4 regression)
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.4.5#code/C4TwDgpgBAQg9nANhAhgOwAouACwM4A8AKgHxQC8UewATgJZoDmUAZALABQUUA3p99wDaAaSgMoAawgg4AMyhEAugC4FIxVAgAPYBDQATPFABGCZOn4DuAfijDLV1UXWadew1DjGAVhADGwA4CtqLaugZGaACuALbGEDRQAD5UtAyMQVa2AAYAJDzCAL4AdPnwSKiY2PjE6iSF2ZkCqmgQAG4JTS3tCQDcloWCUjLySv0c-EA
π» Code
π Actual behavior
This code fails with two errors:
Type alias 'BooleanPaths' circularly references itself.
Type 'BooleanPaths' is not generic.
π Expected behavior
The compilation should pass, as it has in previous versions.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: