-
-
Save jeffmo/043c4aca91faa84ae8298a092b8c0fa5 to your computer and use it in GitHub Desktop.
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 characters
// @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` | |
// $ExpectError | |
//<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 characters
// @flow | |
import {MyConnectedComponent, MyComponent} from './a'; | |
// Flow says `name` and `magic` are missing, which is expected | |
// $ExpectError | |
<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 characters
// @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 characters
> flow version | |
Flow, a static type checker for JavaScript, version 0.44.1 | |
> flow check | |
b.js:7 | |
7: <MyComponent />; | |
^^^^^^^^^^^^^^^ React element `MyComponent` | |
10: export function MyComponent(props: Props) { | |
^^^^^ property `magic`. Property not found in. See: a.js:10 | |
7: <MyComponent />; | |
^^^^^^^^^^^^^^^ props of React element `MyComponent` | |
b.js:7 | |
7: <MyComponent />; | |
^^^^^^^^^^^^^^^ React element `MyComponent` | |
10: export function MyComponent(props: Props) { | |
^^^^^ property `name`. Property not found in. See: a.js:10 | |
7: <MyComponent />; | |
^^^^^^^^^^^^^^^ props of React element `MyComponent` | |
Found 2 errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment