Flow: `const foo = foo` does not produce an error.

Created on 29 Feb 2016  路  4Comments  路  Source: facebook/flow

This little code should produce error (in my opinion) but it doesn't.

const foo = foo;

This should not be a legal ES6 code. Also it's most often wrong.

Eslint can catch that, fortunately, with no-use-before-define.

bug

All 4 comments

Nice catch!

c9dbefcad9c3d124071b096ea12262325c6c31fa

Nice!

I hope this doesn't break things like

const fun = () => {
   if (something) {
       return fun();
   }
   return something;
}

But I can only try :D

Yep, I added new regression tests to make sure that continues to work

Was this page helpful?
0 / 5 - 0 ratings