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.
Activity
bchenSyd commentedon Mar 10, 2017
not fully fixed....
RyanCavanaugh commentedon Mar 10, 2017
@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
truevalue gets quickly widened tobooleanhere because it's not used in a position where it's known to not be mutated.bchenSyd commentedon Mar 11, 2017
hi Ryan, thanks for your reply.
Just so you know that I've walked around the issue by
which does the same as Object.assign