Intersections treat `number` and `boolean` differently

  Kiến thức lập trình

(TypeScript 5.4.5)

It’s easy to understand that

interface A {
  key: string;
  value: string;
}
interface B {
  key: string;
  value: number;
}
type C = A & B // => { key: string; value: never; }
               // ^_^ string & string = string
               //     string & number = never

But when I change number to boolean

interface A {
  key: string;
  value: string;
}
interface B {
  key: string;
  value: boolean;
}
type C = A & B // => never
               // ??? Why not { key: string; value: never; }

LEAVE A COMMENT