verekia / js-stack-walkthrough

Code for each chapter of the JavaScript-Stack-from-Scratch tutorial.
MIT License
30 stars 58 forks source link

Problem with Flow #5

Open AlokBansal8 opened 7 years ago

AlokBansal8 commented 7 years ago

When I run yarn test in chapter 02 after adding the Flow. I get following error:

yarn test v0.24.6
$ eslint src && flow 
Launching Flow server for /Users/alok/Web/FullStack-React
Spawned flow server (pid=28585)
Logs will go to /private/tmp/flow/zSUserszSalokzSWebzSFullStack-React.log
node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js:53
                                                    v--------------------------------------
 53:       const trackChildren: Array<JSXElement> = 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<JSXElement> = node.children.filter((child: Node) => {
                                                    ^^^^^^^^^^^^^^^^^^^^ intersection
  Member 1:
  231:     filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: /private/tmp/flow/flowlib_1ffc7b83/core.js:231
  Error:
                                                                           v-----------------
   53:       const trackChildren: Array<JSXElement> = 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_1ffc7b83/core.js:106
  Member 2:
  232:     filter(callbackfn: (value: T, index: number, array: Array<T>) => any, thisArg?: any): Array<T>;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: /private/tmp/flow/flowlib_1ffc7b83/core.js:232
  Error:
  4924:   children: Array<Node>;
                          ^^^^ 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<JSXElement> = 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

Found 2 errors
error Command failed with exit code 2.
AlokBansal8 commented 7 years ago

Although when I add following lines in .flowconfig file, the above mentioned error goes away:

[ignore]
<PROJECT_ROOT>/node_modules/eslint-plugin-jsx-a11y/src/rules/media-has-caption.js

But I would like to know if you would recommend it. @verekia