From fb85770dbc0965e072b68a7ffa80c1243b8eb087 Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Fri, 26 May 2017 12:05:32 -0400 Subject: [PATCH 1/2] Fixes for Flow v0.47.0 As of v0.47.0 Flow strictly checks function arity. That means you will get an error if you call a function with more arguments than are listed in the function signature. For details see https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/ There are also some changes to checking React component prop types. The latest Flow will report some errors that previous versions missed. The full changelog is here: https://github.com/facebook/flow/blob/master/Changelog.md#0470 --- package.json | 2 +- src/models/StyleSheetManager.js | 6 ++++-- src/test/theme.test.js | 2 +- src/utils/create-broadcast.js | 2 +- yarn.lock | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 20643fb67..a7e750468 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "eslint-plugin-jsx-a11y": "^2.0.2", "eslint-plugin-react": "^6.8.0", "express": "^4.14.1", - "flow-bin": "^0.43.1", + "flow-bin": "^0.47.0", "flow-copy-source": "^1.1.0", "flow-watch": "^1.1.1", "jest": "^19.0.2", diff --git a/src/models/StyleSheetManager.js b/src/models/StyleSheetManager.js index b6b76469f..56834b6ec 100644 --- a/src/models/StyleSheetManager.js +++ b/src/models/StyleSheetManager.js @@ -10,8 +10,10 @@ class StyleSheetManager extends Component { render() { /* eslint-disable react/prop-types */ - // $FlowFixMe - return React.Children.only(this.props.children) + // Flow v0.43.1 will report an error accessing the `children` property, + // but v0.47.0 will not. It is necessary to use a type cast instead of + // a "fixme" comment to satisfy both Flow versions. + return React.Children.only((this.props: any).children) } } diff --git a/src/test/theme.test.js b/src/test/theme.test.js index af042bfa7..499f72101 100644 --- a/src/test/theme.test.js +++ b/src/test/theme.test.js @@ -356,7 +356,7 @@ describe('theming', () => { }, } - const Theme = ({ props }) => ( + const Theme = props => ( diff --git a/src/utils/create-broadcast.js b/src/utils/create-broadcast.js index e83609e27..28c38c897 100644 --- a/src/utils/create-broadcast.js +++ b/src/utils/create-broadcast.js @@ -7,7 +7,7 @@ export type Broadcast = { publish: (value: mixed) => void, - subscribe: (listener: () => void) => () => void + subscribe: (listener: (currentValue: mixed) => void) => () => void } const createBroadcast = (initialValue: mixed): Broadcast => { diff --git a/yarn.lock b/yarn.lock index 87feef57f..54a5ad403 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2499,9 +2499,9 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flow-bin@^0.43.1: - version "0.43.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.43.1.tgz#0733958b448fb8ad4b1576add7e87c31794c81bc" +flow-bin@^0.47.0: + version "0.47.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.47.0.tgz#a2a08ab3e0d1f1cb57d17e27b30b118b62fda367" flow-copy-source@^1.1.0: version "1.1.0" From e7dad01e139158060980d0b9fe516d2c30e1104e Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Sat, 27 May 2017 15:56:58 -0400 Subject: [PATCH 2/2] Note changes to Flow type signatures in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32e545201..d7fe66ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file. If a contri - Restore `setNativeProps` in StyledNativeComponent, thanks to [@MatthieuLemoine](https://github.com/MatthieuLemoine). (see [#764](https://github.com/styled-components/styled-components/pull/764)) - Fix `ref` being passed to Stateless Functional Components in StyledNativeComponent. (see [#828](https://github.com/styled-components/styled-components/pull/828)) - Add `displayName` to `componentId` when both are present (see [#821](https://github.com/styled-components/styled-components/pull/821)) +- Fix Flow type signatures for compatibility with Flow v0.47.0 (see [#840](https://github.com/styled-components/styled-components/pull/840)) ## [v1.4.6] - 2017-05-02