Skip to content
New issue

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

Typeguard typeof !== with || sets never in "else" #55697

Closed
kkmuffme opened this issue Sep 10, 2023 · 3 comments
Closed

Typeguard typeof !== with || sets never in "else" #55697

kkmuffme opened this issue Sep 10, 2023 · 3 comments

Comments

@kkmuffme
Copy link

kkmuffme commented Sep 10, 2023

πŸ”Ž Search Terms

typeguard typeof unknown not or never

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries with the keywords

⏯ Playground Link

https://www.typescriptlang.org/play?#code/FAMwrgdgxgLglgewgAhgBgBQEMBOBzALmUgGsIEB3CASiIGcYc4I9kBvYZL5OEZDVAE8ADgFMEfXKwCEAXlnIA5ACMECADaisERcmrtO3I1CQNkg5AqkBuQ0a45RMMDhSLFtowF9gd5CYgzAC9LZBs-R2dXJQ9gH1BIWEQUGABGbHwiUnIqWmQGJhYDI15+ITEJMPxkOQUVNU1tXQAfZvLxSWrapQLmPF19DntuALMLK3xPYeRIlzdY719jUxhkEIm8a2QAem3kACEAVQBxegALBDB1ABNkZVE7hq0IZt6i5gYtW8qIUQA3UQ4fjqOAkB7MVAAVmoESccxitni4Gg8CQqAAzBlCMQIGRKDR6Iw+sVuKUBDARB0qjJ5EpVBpnroAGRM9qVKQ1WmKN79PQk4ajVbjalTYazaLuUXIeLLQKrdYi2FReaI3zIpJomAAFixWVxOQJ+SJRSGpL45Mp7Oq8jq9MaOj5poFK3MoXC0xmcIlC24MpGLoV7u44pVcTViVRKUhupxeNyhMKrCdPHNbM6rBtdKeTWQrTT1MsXJ5A359kFro2UqMIYRfj9XHLgcmSvhkrDQA

πŸ’» Code

removed

πŸ™ Actual behavior

line 18 "z" is "never"

πŸ™‚ Expected behavior

line 18 "z" is "boolean|string"

Additional information about the issue

No response

@kkmuffme
Copy link
Author

Maybe related to #44366

@Andarist
Copy link
Contributor

I don't see a correlation to #44366 . It's not a bug - your test case is using typeof with two different values and an or condition. Everything is matched by that, even if - let's say - you pass a boolean to this function then it won't be matched by typeof arg !== 'boolean' but will be matched by the alternative condition: typeof arg !== 'string'

@kkmuffme
Copy link
Author

I realized that a day before your reply that's why the issue was closed already ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants