js-stack-from-scratch icon indicating copy to clipboard operation
js-stack-from-scratch copied to clipboard

I got issues after adding flow

Open markandersonus opened this issue 7 years ago • 9 comments

got a lot of issues on section 2 after adding flow.

also dog.js changed from

module.exports = Dog

to

export default Dog

is that correct

ERRORS 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: 245: filter(callbackfn: typeof Boolean): Array<$NonMaybeType<T>>; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: C:\Users\MARK~1.AND\AppData\Local\Temp\flow\flowlib_3a00fe38\core.js:245 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: C:\Users\MARK~1.AND\AppData\Local\Temp\flow\flowlib_3a00fe38\core.js:106 Member 2: 246: filter(callbackfn: (value: T, index: number, array: Array<T>) => any, thisArg?: any): Array<T>; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function type. See lib: C:\Users\MARK~1.AND\AppData\Local\Temp\flow\flowlib_3a00fe38\core.js:246 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

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

Found 3 errors

markandersonus avatar Jul 05 '17 23:07 markandersonus

added to my .flowconfig

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

now just getting:

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

markandersonus avatar Jul 05 '17 23:07 markandersonus

changing dog.js back to...

module.exports = Dog

seems to fix it. is it a problem with the part two under: "Add Flow annotations to src/dog.js like so:"

markandersonus avatar Jul 05 '17 23:07 markandersonus

Just wanted to note that I had the same set of issues as @markandersonus although his proposed fixes didn't solve it in my case. For now I'm just going to remove flow from the test script.

slifty avatar Jul 10 '17 14:07 slifty

I'm seeing the same issues as @slifty - similarly the changes @markandersonus suggests do not fix for me.

maboa avatar Jul 10 '17 14:07 maboa

Looks to be related to this issue -- the solution for me was similar to the above-suggested .flowconfig addition:

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

qwoz avatar Jul 10 '17 21:07 qwoz

I'm using this, found it once somewhere online after a long night of things not working:

[ignore]
<PROJECT_ROOT>/node_modules/.*

Laurian avatar Jul 11 '17 21:07 Laurian

My ignore looks like this and works well for me: [ignore] .*/node_modules/eslint-plugin-jsx-a11y/.*

artemkovalyov avatar Jul 12 '17 10:07 artemkovalyov

Same issue here @qwoz ignore works perfectly in my case

0xhjohnson avatar Jul 13 '17 14:07 0xhjohnson

Had same issue, @qwoz's solution worked

ghost avatar Aug 17 '17 02:08 ghost