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

Flow error? #221

Open
bryndyment opened this issue May 23, 2017 · 5 comments
Open

Flow error? #221

bryndyment opened this issue May 23, 2017 · 5 comments
Labels

Comments

@bryndyment
Copy link

Type of issue: bug

Chapter: 2

If it's a bug:

$ yarn test
yarn test v0.24.5
$ eslint src && flow
node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js:53
v--------------------------------------
53: const trackChildren: Array = node.children.filter((child: Node) => {
54: if (child.type !== 'JSXElement') {
55: return false;
...:
60: });
-^ call of method filter. Function cannot be called on any member of intersection type
53: const trackChildren: Array = node.children.filter((child: Node) => {
^^^^^^^^^^^^^^^^^^^^ intersection
Member 1:
231: filter(callbackfn: typeof Boolean): Array<$NonMaybeType>;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: /private/tmp/flow/flowlib_8895270/core.js:231
Error:
v-----------------
53: const trackChildren: Array = node.children.filter((child: Node) => {
54: if (child.type !== 'JSXElement') {
55: return false;
...:
60: });
^ statics of function. This type is incompatible with
v----------------------
106: declare class Boolean {
107: constructor(value?: mixed): void;
108: static (value:any):boolean;
...:
111: }
^ statics of Boolean. See lib: /private/tmp/flow/flowlib_8895270/core.js:106
Member 2:
232: filter(callbackfn: (value: T, index: number, array: Array) => any, thisArg?: any): Array;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: /private/tmp/flow/flowlib_8895270/core.js:232
Error:
4924: children: Array;
^^^^ object type. This type is incompatible with the expected param type of. See: node_modules/ast-types-flow/lib/types.js:4924
53: const trackChildren: Array = node.children.filter((child: Node) => {
^^^^ Node

node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js:59
59: return isTrackType(context, elementType(child.openingElement));
^^^^^^^^^^^^^^ property openingElement. Property not found in
59: return isTrackType(context, elementType(child.openingElement));
^^^^^ Node

src/index.js:7
7: const toby = new Dog('Toby')
^^^^^^^^^^^^^^^ constructor call. Constructor cannot be called on
7: const toby = new Dog('Toby')
^^^ CommonJS exports of "./dog"

Found 3 errors
error Command failed with exit code 2.

@bryndyment
Copy link
Author

This is the first problem I ran into.

I don't think I deviated from the script, but will check some more.

@bryndyment
Copy link
Author

If I remove "&& flow" from "yarn test", I get:

acme:scratch bryn$ yarn start
yarn start v0.24.5
$ babel-node src
/Users/bryn/scratch/src/index.js:7
var toby = new Dog('Toby');
^

TypeError: Dog is not a constructor
at Object. (/Users/bryn/scratch/src/index.js:7:14)
at Module._compile (module.js:571:32)
at loader (/Users/bryn/scratch/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/bryn/scratch/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function.Module.runMain (module.js:605:10)
at Object. (/Users/bryn/scratch/node_modules/babel-cli/lib/_babel-node.js:154:22)
at Module._compile (module.js:571:32)
error Command failed with exit code 1.

@devserkan
Copy link

Keep flow in your yarn test section. To get rid of the first bug add your .flowconfig file this block:

[ignore]
.*/node_modules/eslint-plugin-jsx-a11y/*

Do not add whole node_modules directory since it causes some other flow check errors.

@ahmadalfy
Copy link

Should this be reported to the eslint plugin?

watadarkstar added a commit to watadarkstar/js-stack-from-scratch that referenced this issue Sep 5, 2017
Going through the guide and I got a flow error running `yarn test`. See:
 verekia#221

The solution is to add:

```
[ignore]
.*/node_modules/eslint-plugin-jsx-a11y/*
```

I propose to add this to the guide so others won't have this issue.
@watadarkstar
Copy link

@bryndyment I put in a PR to fix this, if you want to review it and thumbs up it! #244

@verekia verekia added the bug label Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants