Skip to content

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

Closed
ViKing-Coder-jpg wants to merge 1 commit intomicrosoft:mainfrom
ViKing-Coder-jpg:typee
Closed

Improve satisfies semantics: return never when target type is never#62811
ViKing-Coder-jpg wants to merge 1 commit intomicrosoft:mainfrom
ViKing-Coder-jpg:typee

Conversation

@ViKing-Coder-jpg
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 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
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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