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
Exhaustiveness checking
TS 5.5, v5.6.0-dev.20240729
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABADwIwAoCeAuRBvAL1wHJUAmAZmIF9EAffIxYygFhoEp8BYAKEQGIAzgHcYUCAAssAOgJc8fQcsQQAhkICmzclWxKVhgEYAnTWoDWAbgOH1W5m2L7+hlafPXbKgCabgaiAANlAubiro6AD62GCaAG6aJhwAvAB8eNQcWBw2ruECHpZ5yrR81Hx8oJCwCChkWLiEJLqcPPnCYhLSmHIK3sr22qSUzgNuRV4dyn4BwaHjhpExcYnJ6ZnZmLmL7mbF3mW8FbxV4NDwSMgUjTqj-R2i4lI57eFDd3q7ypMlbrOBEJhAoCZaxBJJVIZLI5P4g36HRDlIA
// ok function x1(y: {z: '123'} | {z: '234'}) { switch(y.z) { case '123': break; case '234': break; default: ((_:never)=>{})(y); break; } } function x2(y: {z: '123'}) { switch(y.z) { case '123': break; default: ((_:never)=>{})(y); // error, y is treated as { z: '123'; } here break; } } // ok function x3(y: '123') { switch(y) { case '123': break; default: ((_:never)=>{})(y); break; } }
function 'x2' get an error : Argument of type '{ z: "123"; }' is not assignable to parameter of type 'never'.
Compile pass, because function 'x1' shows that TS can narrow the parent type and 'x3' shows that TS can narrow non-union type
No response
The text was updated successfully, but these errors were encountered:
Duplicate of #18056 / #23572.
Sorry, something went wrong.
I am experiencing the exact same situation in #23572.
However, if the non-union type is unsupported as described in issue #18056, there should be 2 separate error message for examples 'x2' and 'x3'.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
π Search Terms
Exhaustiveness checking
π Version & Regression Information
TS 5.5, v5.6.0-dev.20240729
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABADwIwAoCeAuRBvAL1wHJUAmAZmIF9EAffIxYygFhoEp8BYAKEQGIAzgHcYUCAAssAOgJc8fQcsQQAhkICmzclWxKVhgEYAnTWoDWAbgOH1W5m2L7+hlafPXbKgCabgaiAANlAubiro6AD62GCaAG6aJhwAvAB8eNQcWBw2ruECHpZ5yrR81Hx8oJCwCChkWLiEJLqcPPnCYhLSmHIK3sr22qSUzgNuRV4dyn4BwaHjhpExcYnJ6ZnZmLmL7mbF3mW8FbxV4NDwSMgUjTqj-R2i4lI57eFDd3q7ypMlbrOBEJhAoCZaxBJJVIZLI5P4g36HRDlIA
π» Code
π Actual behavior
function 'x2' get an error : Argument of type '{ z: "123"; }' is not assignable to parameter of type 'never'.
π Expected behavior
Compile pass, because function 'x1' shows that TS can narrow the parent type and 'x3' shows that TS can narrow non-union type
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: