Open
Description
Bug Report
🔎 Search Terms
intersection assign never
🕗 Version & Regression Information
This is the behavior in every version I tried (including nightly), and I reviewed the FAQ for relevant entries. But really this is a loose end left by #36696; prior to that the impossible intersection (AB
below) was not never
at all.
⏯ Playground Link
💻 Code
(modified from the example in #36696)
type A = { kind: 'a', foo: string };
type B = { kind: 'b', foo: number };
type AB = A & B; // never, supposedly
// @ts-expect-error: Type 'any' is not assignable to type 'never'.
const n1: never = {} as any
// but this is ok
const n2: AB = {} as any
🙁 Actual behavior
any
is assignable to AB
, despite the fact that any
is not assignable to never
and AB
is supposedly never
(per both #36696 and hovering it)
🙂 Expected behavior
any
should not be assignable to AB