Bug Report
🔎 Search Terms
inference common base type null undefined
🕗 Version & Regression Information
- This changed between versions 4.7.3 and 4.8-beta
⏯ Playground Link
Playground link with relevant code
💻 Code
functionequal<T>(a: T,b: T){}letv=null!;// Object types with common base typestypeB={foo: string}typeD={foo: string;bar: number}// Error in 4.8 TS can't find common type ❌// 4.7 T was undefined | Bequal(vasB,vasundefined|D)// ok T is B ✅equal(vasB,vasD)// ok T is B | undefined ✅equal(vasB,vasB|undefined)🙁 Actual behavior
In 4.8 TypeScript can't find common base type between B and undefined | D. In 4.7 this used to be B | undefined.
This also happens for literal types and their respective base types as well as for arrays as shown in the 'Other Examples' in the playground link. I didn't include the code as the bug is the same, it's just different instances we found in our code.
🙂 Expected behavior
Typescript finds the type B | undefined for T as it did in 4.7.
Bug Report
🔎 Search Terms
inference common base type null undefined
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
In 4.8 TypeScript can't find common base type between
Bandundefined | D. In 4.7 this used to beB | undefined.This also happens for literal types and their respective base types as well as for arrays as shown in the 'Other Examples' in the playground link. I didn't include the code as the bug is the same, it's just different instances we found in our code.
🙂 Expected behavior
Typescript finds the type
B | undefinedforTas it did in 4.7.