microsoft / microsoft/TypeScript
Impossible intersection is supposedly never but any can still be assigned to it
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground reproduction and read the behavior described in #36696. Confirm the discrepancy between never and AB; done means the example rejects assigning any to AB while preserving the related intersection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100