-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
true extends false #28654
Comments
This has no problems in either TS 3.2 or TS 3.0.1 type G<B extends boolean> = (
true extends B?
["Actual", "true extends", B] :
"Expected"
)
//OK
//Expected: "Expected"
//Actual: "Expected"
type g = G<false>; |
I think this is happening because of #27470 In type G2<DataT extends { b : boolean }, B extends keyof DataT> = (
true extends DataT[B]?
["Actual", "true extends", DataT[B]] :
"Expected"
)
// g2: "Expected"
type g2 = G2<{ b: false }, "b">; or even doing: type G2<DataT extends { b : boolean }, B extends "b"> = (
true extends DataT[B]?
["Actual", "true extends", DataT[B]] :
"Expected"
)
// g2: "Expected"
type g2 = G2<{ b: false }, "b">; |
Yikes. I hope this is fixed. This breaks a lot of my code that was working in 3.0.1. Using your workaround would make the type declarations even more verbose and complex =( Thank you for looking into it! I had this gnawing at me even as I tried to sleep. I guess I'll hold off on upgrading TS for now :x |
This might be related to some problems I found while working on the React types; proving that |
Simplified repro with expected outcomes: type Foo<T extends { b: boolean }> = true extends T["b"] ? "yes" : "no";
type T0 = Foo<{ b: never }> // "no"
type T1 = Foo<{ b: false }>; // "no"
type T2 = Foo<{ b: true }>; // "yes"
type T3 = Foo<{ b: boolean }>; // "yes" Currently |
Thank you for fixing this so quickly! I just updated from |
TypeScript Version: 3.2.0-dev.20181117
EDIT: I just tested with TS 3.2.0-rc and it has this bug
Search Terms: true extends false
Code
I feel like I'm losing my mind here. Or maybe I'm tired because it's 3.34am. Maybe I need to take a break. Am I missing something obvious?
Expected behavior:
g
to be of type"Expected"
.Intuitively,
DataT
is of type{ b : false }
DataT["b"]
is of typefalse
true extends false
should be...false
Actual behavior:
g
is of type["Actual", "true extends", false]
Playground Link: Here
EDIT: I just tested and this is not a problem in TS 3.0.1
I'm not crazy, phew.
The text was updated successfully, but these errors were encountered: