TypeScript Version: 2.1.1
Code
interface StdoutValue {
stdout: string;
stderr?: undefined;
}
interface StderrValue {
stdout?: undefined;
stderr: string;
}
type StreamValue = StdoutValue | StderrValue;
const stream: Array<StreamValue> = [
{ stdout: 'foo' },
{ stderr: 'bar' }
];
console.log(stream.map(value => value.stderr === undefined ? value.stdout.toUpperCase() : value.stderr.toUpperCase()));
Expected behavior:
No error with strict null checks.
Actual behavior:
Thinks value.stdout could be undefined on last line, but this is not possible.
TypeScript Version: 2.1.1
Code
Expected behavior:
No error with strict null checks.
Actual behavior:
Thinks
value.stdoutcould beundefinedon last line, but this is not possible.