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

No error on properties access inside a if statement #130

Closed
fdecampredon opened this issue Nov 25, 2014 · 3 comments
Closed

No error on properties access inside a if statement #130

fdecampredon opened this issue Nov 25, 2014 · 3 comments

Comments

@fdecampredon
Copy link

var a = { x: 4, y: 2 };
// No error (??)
if(a.z.w) { }

Originally reported in typescript discussion see: microsoft/TypeScript#1265 (comment)

@avikchaudhuri
Copy link
Contributor

Duplicate of #106

@jfirebaugh
Copy link

This is still an issue, and doesn't look like a duplicate of #106 to me -- there's no function involved.

@asolove
Copy link
Contributor

asolove commented Sep 30, 2017

Yeah, this is definitely a different issue. But it’s also a semi deliberate one. Flow allows extra properties on objects inside if tests, which in cases like this can lead to run time exceptions.

I would guess this behavior is not going away because I exact object types have some uses and that the flow team would encourage the use of exact object types to prevent this kind of problem if you don’t need that flexibility.

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

4 participants