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
{{ message }}
Repository navigation
A strange behavior when checking extends ReadonlyArray<any>Β #59430
changed the title [-]A strange behavior when checking `extends Readonly<any>`[/-][+]A strange behavior when checking `extends ReadonlyArray<any>`[/+]on Jul 26, 2024
Ryan Cavanaugh (@RyanCavanaugh) Are we sure this is a bug? The type B extends ReadonlyArray<any> ? B : B is a substitution type like B & ReadonlyArray<any> (due to #37348), and that intersection is indeed allowed in AcceptA because of the unsoundness of any. It's weird, but why would someone write B extends ReadonlyArray<any> ? B : B in the first place except to expose some substitution-type behavior?
Activity
[-]A strange behavior when checking `extends Readonly<any>`[/-][+]A strange behavior when checking `extends ReadonlyArray<any>`[/+]jcalz commentedon Jul 26, 2024
SO question
Ryan Cavanaugh (@RyanCavanaugh) Are we sure this is a bug? The type
B extends ReadonlyArray<any> ? B : Bis a substitution type likeB & ReadonlyArray<any>(due to #37348), and that intersection is indeed allowed inAcceptAbecause of the unsoundness ofany. It's weird, but why would someone writeB extends ReadonlyArray<any> ? B : Bin the first place except to expose some substitution-type behavior?RyanCavanaugh commentedon Jul 26, 2024
Joe Calzaretta (@jcalz) yeah, good observation. I agree
ruojianll commentedon Jul 27, 2024
Joe Calzaretta (@jcalz) Ryan Cavanaugh (@RyanCavanaugh) But isn't it a bug?
Test3shouldn't acceptBin result.ruojianll commentedon Jul 27, 2024
The true value
Bis should not beB & ReadonlyArray<any>. If the condition is true, why do we need to narrow down the true value?ruojianll commentedon Jul 29, 2024
I still consider it as a bug. Anders Hejlsberg (@ahejlsberg)
typescript-bot commentedon Aug 1, 2024
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes.