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
Hello!
Thank you for your hard work.
Please, consider this code:
class Foo { foo: string; } class Bar { bar: string; } function foo(value: Foo | Bar) { const isFoo = value instanceof Foo; const isBar = !isFoo && value.bar; // <-- causes error }
The line above throws an error:
Property 'bar' does not exist on type 'Foo | Bar'. Property 'bar' does not exist on type 'Foo'.
However, if I replace the logical variable with the expression directly, it works:
const isBar = !(value instanceof Foo) && value.bar;
The isFoo variable in my example is a boolean constant, it's value can't change, so I believe it should be statically analyzable.
isFoo
The text was updated successfully, but these errors were encountered:
Typescript don't track related variables.
Sorry, something went wrong.
Duplicate of #12184
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Successfully merging a pull request may close this issue.
Hello!
Thank you for your hard work.
Please, consider this code:
The line above throws an error:
However, if I replace the logical variable with the expression directly, it works:
The
isFoo
variable in my example is a boolean constant, it's value can't change, so I believe it should be statically analyzable.The text was updated successfully, but these errors were encountered: