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
interfaceGood{ok: true,data: string,}interfaceBad{ok: false,}typeResult=Good|Bad;functionconvertPromiseDoesntCompile(p: Promise<string>): Promise<Result>{returnp.then((data: string)=>({ok: true, data }),()=>({ok: false}));}functionconvertPromiseCompiles(p: Promise<string>): Promise<Result>{returnp.then((data: string)=>({ok: trueastrue, data }),()=>({ok: falseasfalse}));}
Expected behavior:
Compiles without the uselessly looking casts
Actual behavior:
Type 'Promise<{ ok: boolean; data: string; } | { ok: boolean; }>' is not assignable to type 'Promise<Result>'.
Type '{ ok: boolean; data: string; } | { ok: boolean; }' is not assignable to type 'Result'.
Type '{ ok: boolean; data: string; }' is not assignable to type 'Result'.
Type '{ ok: boolean; data: string; }' is not assignable to type 'Bad'.
Types of property 'ok' are incompatible.
Type 'boolean' is not assignable to type 'false'.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version:
2.8.3
2.9.0-rc
3.0.0-dev.20180522
Search Terms:
true as true
Code
Expected behavior:
Compiles without the uselessly looking casts
Actual behavior:
Playground Link:
https://www.typescriptlang.org/play/index.html#src=interface%20Good%20%7B%0D%0A%20%20%20%20ok%3A%20true%2C%0D%0A%20%20%20%20data%3A%20string%2C%0D%0A%7D%0D%0A%0D%0Ainterface%20Bad%20%7B%0D%0A%20%20%20%20ok%3A%20false%2C%0D%0A%7D%0D%0A%0D%0Atype%20Result%20%3D%20Good%20%7C%20Bad%3B%0D%0A%0D%0Afunction%20convertPromiseDoesntCompile(p%3A%20Promise%3Cstring%3E)%3A%20Promise%3CResult%3E%20%7B%0D%0A%20%20%20%20return%20p.then(%0D%0A%20%20%20%20%20%20%20%20(data%3A%20string)%20%3D%3E%20(%7B%20ok%3A%20true%2C%20data%20%7D)%2C%0D%0A%20%20%20%20%20%20%20%20()%20%3D%3E%20(%7B%20ok%3A%20false%20%7D)%0D%0A%20%20%20%20)%3B%0D%0A%7D%0D%0A%0D%0Afunction%20convertPromiseCompiles(p%3A%20Promise%3Cstring%3E)%3A%20Promise%3CResult%3E%20%7B%0D%0A%20%20%20%20return%20p.then(%0D%0A%20%20%20%20%20%20%20%20(data%3A%20string)%20%3D%3E%20(%7B%20ok%3A%20true%20as%20true%2C%20data%20%7D)%2C%0D%0A%20%20%20%20%20%20%20%20()%20%3D%3E%20(%7B%20ok%3A%20false%20as%20false%7D)%0D%0A%20%20%20%20)%3B%0D%0A%7D
Related Issues:
#21427
The text was updated successfully, but these errors were encountered: