TypeScript Version: 3.2.0-rc
Search Terms:
refinement
Code
(EDIT: incorrect reproduction, see correct example at #28568 (comment))
functiontest(x: {type: 'a';body: string|null}|{type: 'b';body: number|null}): string{if(x.body===null){return'null'}x.body.toString()// okif(x.type==='a'){returnx.body.toString()// x.body may be null}else{returnx.body.toString()// x.body may be null}}Expected behavior:
The refinement of x.body should persist (it does in 3.1)
Actual behavior:
TS forgets that it has already refined x.body to be not null.
TypeScript Version: 3.2.0-rc
Search Terms:
refinement
Code
(EDIT: incorrect reproduction, see correct example at #28568 (comment))
Expected behavior:
The refinement of
x.bodyshould persist (it does in 3.1)Actual behavior:
TS forgets that it has already refined
x.bodyto be notnull.