Skip to content

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

Open
@benjaminjkraft

Description

@benjaminjkraft

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions