TypeScript Version: 2.1.5
Code
Minimal example that compiles just fine:
letx: Promise<string|undefined>=Promise.resolve(undefined);lety: Promise<string>=x;
Small usage example in which I encountered the bug:
interfaceITest{test(): Promise<string>;}classTestimplementsITest{test(): Promise<string|undefined>{returnPromise.resolve(undefined);}}vartest=newTest();test.test().then(console.log);Expected behavior:
A compile error: the type Promise<string | undefined> does not match the type Promise<string>. I should not be able to cast undefined to string.
Actual behavior:
No errors.
TypeScript Version: 2.1.5
Code
Minimal example that compiles just fine:
Small usage example in which I encountered the bug:
Expected behavior:
A compile error: the type
Promise<string | undefined>does not match the typePromise<string>. I should not be able to castundefinedtostring.Actual behavior:
No errors.