Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flow Generator type is not being recognized by eslint

I'm using eslint with flowtype. It was working perfectly until I decided to use es6 generators. When I export a generator, I need to specify the return type but eslint is not recognizing the Generator type.

export function *gen2(): Generator {
  yield 'test';
}

Eslint shows this error: 'Generator' is not defined. but flow works perfectly.

Anyone has any idea on how to make eslint recognize the Generator type?

like image 902
Luiz Guilherme Avatar asked May 13 '16 21:05

Luiz Guilherme


1 Answers

There is no global Generator constructor in JS, so ESLint will see that as unknown. You'll need to add it to your .eslintrc as a global, e.g.

{
  "rules": {},
  "globals": {
    "Generator": true
  }
}
like image 185
loganfsmyth Avatar answered Nov 04 '22 04:11

loganfsmyth