codemix / babel-plugin-typecheck

Static and runtime type checking for JavaScript in the form of a Babel plugin.
MIT License
886 stars 44 forks source link

TypeError for `for` loop nested under `if` statement without braces #162

Closed mhelvens closed 7 years ago

mhelvens commented 8 years ago

I have this piece of code that doesn't compile because of babel-plugin-typecheck:

if (RelSubclass) for (let subDomain of RelSubclass.domains) {} // ERROR

It produces the error: Expected _RelSubclass$domains to be iterable, got void

Everything works fine if the if statement has braces:

if (RelSubclass) { for (let subDomain of RelSubclass.domains) {} } // OK
phpnode commented 7 years ago

Hi, sorry for taking so long to respond to this, this project is now deprecated in favour of https://codemix.github.io/flow-runtime which aims for full compatibility with Flow.

I checked and babel-plugin-flow-runtime does not have this particular bug.

mhelvens commented 7 years ago

Ah, OK. Thanks for the heads up!