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
typeA={x:string}|{x:number}|{x: symbol}typeB={x:string}|{x:number}|{x: boolean}// ^ literal type heretypeC={x:string}|{x:number}typeX={x:string|number}// `X extends B` but not A or CtypeX_A=XextendsA ? "X extends A" : "X not extends A";// ^? X not extends AtypeX_B=XextendsB ? "X extends B" : "X not extends B";// ^? X extends BtypeX_C=XextendsC ? "X extends C" : "X not extends C";// ^? X not extends C
the bug is reproduced with any literal type instead of boolean
π Actual behavior
X not extends A X extends B; X not extends C
π Expected behavior
X not extends A X not extends B X not extends C
The text was updated successfully, but these errors were encountered:
#30779 implemented this behavior intentionally, and it is documented in the TS3.5 release notes. Unions with discriminant-worthy properties (involving literals) are related differently, on purpose. That results in:
Bug Report
π Search Terms
π Version & Regression Information
extends
operatorβ― Playground Link
https://www.typescriptlang.org/play?ts=5.1.0-beta#code/C4TwDgpgBAglC8UDeAPAXAZ2AJwJYDsBzAXygB9l18BXAWwCMJtSLU0oMQGB7AG2IBQA0JCgAhBJUw4CJclJoMmLKVHrc+EAIb5BUfQcNHjJ0wYD05qAD0ovXMCZbeUEdAAWTCMPDQAwpJsWHhEKmyKjMxCblAAGoHowbLyEcoCllAABvEQKI74ACYY4plq1MBQ+NwVcNzYUH5CPqKxAPpwiDl5EIXFcAD8UABEXflFsENQ7COV1VC5Y31DANzpVvrW-dG+ca0SnfPdveJQgzMLPeNik9PxVRUXx9erGRtbzdBtAQeP4wFno0uxT8N2Gdzmv2BKzWBk221EMFa8UQcEhcVOw1RR3GsVBQzg90Oizi0NeNneMTESMkEjR8TOtOxxVxU2GEkJdNJ63J8P81MQATpGKGgqZJNZItmDzFuJe3LhQA
π» Code
the bug is reproduced with any literal type instead of
boolean
π Actual behavior
X
not extendsA
X
extendsB
;X
not extendsC
π Expected behavior
X
not extendsA
X
not extendsB
X
not extendsC
The text was updated successfully, but these errors were encountered: