Closed
Description
TypeScript Version: 2.1.4 (2.2.0-dev.20161218 also)
Code
With --strictNullChecks,
interface Foo {
prop: string;
}
function nullableFooPromise(): Promise<Foo | null> {
return Promise.resolve(null);
}
nullableFooPromise()
.then(nullableFoo => nullableFoo ? nullableFoo : { prop: 'foo' })
.then(foo => console.log(foo.prop)); // this line raises an error
Expected behavior:
I expect this to compile (it does actually when I use [email protected]).
Actual behavior:
I get an error,
index.ts(11,28): error TS2531: Object is possibly 'null'.