Skip to content

Commit

Permalink
Added defs for Flow 0.53 (thanks mwiencek!)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGilleran committed Aug 20, 2017
1 parent 823bcc9 commit acf380c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ to lint your code.

### FlowType
There's still not a perfect solution for FlowType given that it doesn't provide a lot of plugin functionality
(at least not yet). Flow definitions are available in `jsx-control-statements.flow.js`, which will stop the
(at least not yet). Flow definitions are available in `jsx-control-statements.latest.flow.js` for Flow >= 0.53, or `jsx-control-statements.flow.js` (deprecated) for Flow < 0.53. These will stop the
type checker complaining about statements being undeclared. As of now there's no neat way to make the Flow checker
recognise `each` attributes in `<For>` loops as a variable - the best workaround for now is something like:

Expand Down
10 changes: 7 additions & 3 deletions jsx-control-statements.flow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// @flow

declare var If: ReactClass<{condition: boolean}>;
declare var For: ReactClass<{each: string, index: string, of: Array<any>}>;
// DEPRECATION NOTICE: If you're using Flow >= 0.53 please use the defs in the
// jsx-control-statements.latest.flow.js file. These are deprecated and will
// eventually be replaced by the defs in that file.

declare var If: ReactClass<{ condition: boolean }>;
declare var For: ReactClass<{ each: string, index: string, of: Array<any> }>;
declare var Choose: ReactClass<{}>;
declare var When: ReactClass<{condition: boolean}>;
declare var When: ReactClass<{ condition: boolean }>;
declare var Otherwise: ReactClass<{}>;
7 changes: 7 additions & 0 deletions jsx-control-statements.latest.flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @flow

declare var If: React$ComponentType<{condition: boolean}>;
declare var For: React$ComponentType<{each: string, index: string, of: Array<any>}>;
declare var Choose: React$ComponentType<{}>;
declare var When: React$ComponentType<{condition: boolean}>;
declare var Otherwise: React$ComponentType<{}>;

0 comments on commit acf380c

Please sign in to comment.