We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript Version: nightly
Code
type SkippedError = { tag: "Skipped" }; const error: SkippedError = {} as any; switch (error.tag) { case "Skipped": const a1: SkippedError = error; return 1; default: const a2: never = error; return 0; }
Expected behavior: Exhaustive check should narrow error type to never for a2.
error
never
a2
Actual behavior: Type 'SkippedError' is not assignable to type 'never'.(2322)
Type 'SkippedError' is not assignable to type 'never'.(2322)
The type of error at the a2 is still SkippedError
SkippedError
if
instanceof
Playground Link: Playground Link
The text was updated successfully, but these errors were encountered:
when union has only 1 type
What union? You don't have a union type.
Duplicate of #16976.
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: nightly
Code
Expected behavior:
Exhaustive check should narrow
error
type tonever
fora2
.Actual behavior:
Type 'SkippedError' is not assignable to type 'never'.(2322)
The type of error at the
a2
is stillSkippedError
error
has 2 types and code works correctly.if
has same result.instanceof
, but can not be applied for literals.Playground Link: Playground Link
The text was updated successfully, but these errors were encountered: