/a.js
Created
April 19, 2017 21:31
Revisions
-
jeffmo created this gist
Apr 19, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ // @flow import {connect} from './connect'; type Props = { name: string, magic: number, }; export function MyComponent(props: Props) { return <div />; } export const MyConnectedComponent = connect(MyComponent, { magic: 42 }); // Flow says only `name` is missing, which is correct since we "connected" `magic` //<MyConnectedComponent />; // export MyConnectedComponent; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // @flow import {MyConnectedComponent, MyComponent} from './a'; // Flow says `name` and `magic` are missing, which is expected <MyComponent />; // Flow is fine with this one? <MyConnectedComponent />; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // @flow type Component<P> = (props: P) => any; export function connect<P, E>(component: Component<P>, extra: E): Component<$Diff<P, E>> { return (component: any); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ > flow version Flow, a static type checker for JavaScript, version 0.44.1 > flow check b.js:6 6: <MyComponent />; ^^^^^^^^^^^^^^^ React element `MyComponent` 10: export function MyComponent(props: Props) { ^^^^^ property `magic`. Property not found in. See: a.js:10 6: <MyComponent />; ^^^^^^^^^^^^^^^ props of React element `MyComponent` b.js:6 6: <MyComponent />; ^^^^^^^^^^^^^^^ React element `MyComponent` 10: export function MyComponent(props: Props) { ^^^^^ property `name`. Property not found in. See: a.js:10 6: <MyComponent />; ^^^^^^^^^^^^^^^ props of React element `MyComponent` Found 2 errors