- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.1k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: 2.1.5
Code
Minimal example that compiles just fine:
let x: Promise<string | undefined> = Promise.resolve(undefined);
let y: Promise<string> = x;Small usage example in which I encountered the bug:
interface ITest {
    test(): Promise<string>;
}
class Test implements ITest{
    test(): Promise<string | undefined> {
        return Promise.resolve(undefined);
    }
}
var test = new Test();
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.
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed