Skip to content

Improve satisfies semantics: return never when target type is never - #62811

Closed
Vinayak Mohakud (Vynxvoid) wants to merge 1 commit into
microsoft:mainfrom
Vynxvoid:typee
Closed

Improve satisfies semantics: return never when target type is never#62811
Vinayak Mohakud (Vynxvoid) wants to merge 1 commit into
microsoft:mainfrom
Vynxvoid:typee

Conversation

@Vynxvoid

Copy link
Copy Markdown

PR: Make satisfies Narrow to never When Target Type Is never

Issue---> #62807 — "Switch doesn't narrow type when type isn't a discriminated union"

This PR updates the TypeScript compiler so that a satisfies expression produces the type never when its target type is exactly the intrinsic never type. This allows patterns like:
assertNever(foo satisfies never);

@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 27, 2025
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 27, 2025
@typescript-bot

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@MartinJohns

Copy link
Copy Markdown
Contributor

Won't this change allow foo satisfies never when foo does not satisfy never?

@RyanCavanaugh

Copy link
Copy Markdown
Member

I don't understand the goal here and this isn't an approved change. In foo satisfies never, if foo isn't never, the program already has an error, so this doesn't change whether or not the line assertNever(foo satisfies never) has an error, and it's not clear why you'd write assertNever(foo satisfies never) in the first place -- assertNever(foo) is equivalent.

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Dec 1, 2025
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Jun 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants