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
result.ts(5,16): error TS2322: Type '{ success: boolean; value: number; }' is not assignable to type 'Result<number>'.
Type '{ success: boolean; value: number; }' is not assignable to type '{ success: false; }'.
Types of property 'success' are incompatible.
Type 'boolean' is not assignable to type 'false'.
result.ts(8,16): error TS2322: Type '{ success: boolean; }' is not assignable to type 'Result<number>'.
Type '{ success: boolean; }' is not assignable to type '{ success: false; }'.
Types of property 'success' are incompatible.
Type 'boolean' is not assignable to type 'false'.
If I add manual type annotations (true as true, false as false) to the success assignments it works:
@bochen2014 I don't see how we could fix that case. In general we don't assume that functions won't modify a type within its own domain, and the true value gets quickly widened to boolean here because it's not used in a position where it's known to not be mutated.
TypeScript Version: nightly (2.1.0-dev.20160818)
Code
I lifted this from Anders's final example in #9407 (comment).
Expected behavior:
Type-checks OK
Actual behavior:
Type error:
If I add manual type annotations (
true as true
,false as false
) to thesuccess
assignments it works:The bug only affects Boolean literals. If I use enum, number, or string type literals it works - for example:
The text was updated successfully, but these errors were encountered: