Skip to content

if does not guard unkown not null correctly #44971

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

Closed
JounQin opened this issue Jul 11, 2021 · 2 comments
Closed

if does not guard unkown not null correctly #44971

JounQin opened this issue Jul 11, 2021 · 2 comments

Comments

@JounQin
Copy link

JounQin commented Jul 11, 2021

Bug Report

πŸ”Ž Search Terms

if unkown null

πŸ•— Version & Regression Information

typescript@next

This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

declare const error: unknown

if (error) {
  throw typeof error === 'object' && 'message' in error ? Object.assign(new Error(), error) : error
}

πŸ™ Actual behavior

Object is possibly 'null'.

πŸ™‚ Expected behavior

No error, if (error) has already ensured error will never be null.

@whzx5byb
Copy link

Duplicate of #28131

@JounQin
Copy link
Author

JounQin commented Jul 11, 2021

Thanks.

@JounQin JounQin closed this as completed Jul 11, 2021
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