Bug Report
🔎 Search Terms
- type guard
- inference
- if condition
🕗 Version & Regression Information
This is a regression.
Inference was OK on 4.7.4 but broken on 4.8.4 and 4.9.5 (tested on the playground).
⏯ Playground Link
Playground link with relevant code
💻 Code
exporttypeWritable<T>={-readonly[KinkeyofT]: T[K];};classFoo{readonlyfoo='foo';}classBar{readonlybar='bar';}typeWritableFooBar=Writable<Foo|Bar>;declarefunctionisFoo(obj: any): obj is Foo;functiontest(foobar: WritableFooBar): void{if(!isFoo(foobar)){}// happens also with if(isFoo())foobar// ^? Foo | Writable<Bar>}🙁 Actual behavior
foobar is inference as Foo | Writable<Bar>
🙂 Expected behavior
foobar should be inferred as Writable<Foo|Bar> or WritableFooBar
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
This is a regression.
Inference was OK on
4.7.4but broken on4.8.4and4.9.5(tested on the playground).⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
foobaris inference asFoo | Writable<Bar>🙂 Expected behavior
foobarshould be inferred asWritable<Foo|Bar>orWritableFooBar