microsoft / microsoft/TypeScript

Impossible intersection is supposedly never but any can still be assigned to it

Open
#53,027 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.