From a16ef18a803579c84c77df0274a148cafb83baaa Mon Sep 17 00:00:00 2001 From: Sam Goldman Date: Mon, 2 Oct 2017 20:59:10 -0700 Subject: [PATCH] Upgrade Flow to v0.56.0 Reviewed By: calebmer Differential Revision: D5958715 fbshipit-source-id: 7feda03a9540e69bf8d9b4eb89720248ff43294f --- .flowconfig | 6 +++--- Libraries/Components/ScrollView/ScrollView.js | 1 - Libraries/Core/InitializeCore.js | 6 ++++++ Libraries/Image/ImageBackground.js | 3 --- Libraries/Lists/VirtualizedList.js | 18 ------------------ Libraries/StyleSheet/StyleSheetValidation.js | 12 ++++++++++++ local-cli/bundle/buildBundle.js | 7 +++++-- local-cli/server/util/attachHMRServer.js | 6 ++++++ local-cli/templates/HelloWorld/_flowconfig | 6 +++--- local-cli/util/__tests__/fs-mock-test.js | 9 +++++++++ package.json | 2 +- 11 files changed, 45 insertions(+), 31 deletions(-) diff --git a/.flowconfig b/.flowconfig index 683702d26..6ceb63fe5 100644 --- a/.flowconfig +++ b/.flowconfig @@ -46,12 +46,12 @@ suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-4]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-4]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError unsafe.enable_getters_and_setters=true [version] -^0.54.0 +^0.56.0 diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index fcf9230a3..d7afb8246 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -912,7 +912,6 @@ if (Platform.OS === 'android') { (ScrollView: React.ComponentType), nativeOnlyProps, ); - // $FlowFixMe (bvaughn) Update ComponentInterface in ViewPropTypes to include a string type (for Fiber host components) in a follow-up. RCTScrollContentView = requireNativeComponent('RCTScrollContentView', View); } diff --git a/Libraries/Core/InitializeCore.js b/Libraries/Core/InitializeCore.js index dcf3a6401..63482c521 100644 --- a/Libraries/Core/InitializeCore.js +++ b/Libraries/Core/InitializeCore.js @@ -232,6 +232,12 @@ if (__DEV__) { // Set up inspector const JSInspector = require('JSInspector'); + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ + /* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This comment + * suppresses an error found when Flow v0.56 was deployed. To see the error + * delete this comment and run Flow. */ JSInspector.registerAgent(require('NetworkAgent')); } } diff --git a/Libraries/Image/ImageBackground.js b/Libraries/Image/ImageBackground.js index f5229e53c..92da9ebe7 100644 --- a/Libraries/Image/ImageBackground.js +++ b/Libraries/Image/ImageBackground.js @@ -58,9 +58,6 @@ class ImageBackground extends React.Component<$FlowFixMeProps> { _viewRef: ?NativeMethodsMixinType = null; _captureRef = ref => { - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment - * suppresses an error when upgrading Flow's support for React. To see the - * error delete this comment and run Flow. */ this._viewRef = ref; }; diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index d327ec30d..c1f241374 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -375,18 +375,12 @@ class VirtualizedList extends React.PureComponent { */ getScrollResponder() { if (this._scrollRef && this._scrollRef.getScrollResponder) { - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ return this._scrollRef.getScrollResponder(); } } getScrollableNode() { if (this._scrollRef && this._scrollRef.getScrollableNode) { - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ return this._scrollRef.getScrollableNode(); } else { return ReactNative.findNodeHandle(this._scrollRef); @@ -395,9 +389,6 @@ class VirtualizedList extends React.PureComponent { setNativeProps(props: Object) { if (this._scrollRef) { - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ this._scrollRef.setNativeProps(props); } } @@ -636,9 +627,6 @@ class VirtualizedList extends React.PureComponent { ); cells.push( - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ { ); cells.push( - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ { ); cells.push( - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This - * comment suppresses an error when upgrading Flow's support for React. - * To see the error delete this comment and run Flow. */ =0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ + /* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This + * comment suppresses an error found when Flow v0.56 was deployed. To see + * the error delete this comment and run Flow. */ styleError(message1, style, caller, message2); } var error = allStylePropTypes[prop]( @@ -43,6 +49,12 @@ class StyleSheetValidation { ReactPropTypesSecret, ); if (error) { + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ + /* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This + * comment suppresses an error found when Flow v0.56 was deployed. To see + * the error delete this comment and run Flow. */ styleError(error.message, style, caller); } } diff --git a/local-cli/bundle/buildBundle.js b/local-cli/bundle/buildBundle.js index d04bb0e1e..8b974088a 100644 --- a/local-cli/bundle/buildBundle.js +++ b/local-cli/bundle/buildBundle.js @@ -50,9 +50,12 @@ import type {ConfigT} from 'metro-bundler'; function saveBundle(output, bundle, args) { return Promise.resolve( - /* $FlowFixMe(>=0.54.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.54 was deployed. To see the error delete this + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this * comment and run Flow. */ + /* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This comment + * suppresses an error found when Flow v0.56 was deployed. To see the error + * delete this comment and run Flow. */ output.save(bundle, args, log) ).then(() => bundle); } diff --git a/local-cli/server/util/attachHMRServer.js b/local-cli/server/util/attachHMRServer.js index 1ca1f1a1a..184eb78fe 100644 --- a/local-cli/server/util/attachHMRServer.js +++ b/local-cli/server/util/attachHMRServer.js @@ -189,6 +189,12 @@ function attachHMRServer( Array.from(dependents).map(getModuleId); } + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ + /* $FlowFixMe(>=0.56.0 site=react_native_fb,react_native_oss) This comment + * suppresses an error found when Flow v0.56 was deployed. To see the error + * delete this comment and run Flow. */ return { dependenciesCache, dependenciesModulesCache, diff --git a/local-cli/templates/HelloWorld/_flowconfig b/local-cli/templates/HelloWorld/_flowconfig index 837c16729..1ac2a7be5 100644 --- a/local-cli/templates/HelloWorld/_flowconfig +++ b/local-cli/templates/HelloWorld/_flowconfig @@ -37,12 +37,12 @@ suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-4]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-4]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError unsafe.enable_getters_and_setters=true [version] -^0.54.0 +^0.56.0 diff --git a/local-cli/util/__tests__/fs-mock-test.js b/local-cli/util/__tests__/fs-mock-test.js index c4df35aa3..c390e3cf2 100644 --- a/local-cli/util/__tests__/fs-mock-test.js +++ b/local-cli/util/__tests__/fs-mock-test.js @@ -28,10 +28,16 @@ describe('fs mock', () => { it('stores content correctly', () => { fs.writeFileSync('/test', 'foobar', 'utf8'); const content = fs.readFileSync('/test', 'utf8'); + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ expect(content).toEqual('foobar'); }); it('fails on missing path', () => { + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ expect(() => fs.writeFileSync('/dir/test', 'foobar', 'utf8'), ).toThrowError('ENOENT: no such file or directory'); @@ -43,6 +49,9 @@ describe('fs mock', () => { fs.mkdirSync('/dir', 0o777); fs.writeFileSync('/dir/test', 'foobar', 'utf8'); const content = fs.readFileSync('/dir/test', 'utf8'); + /* $FlowFixMe(>=0.56.0 site=react_native_oss) This comment suppresses an + * error found when Flow v0.56 was deployed. To see the error delete this + * comment and run Flow. */ expect(content).toEqual('foobar'); }); }); diff --git a/package.json b/package.json index 68f031964..076bc83dd 100644 --- a/package.json +++ b/package.json @@ -198,7 +198,7 @@ "eslint-plugin-flowtype": "^2.33.0", "eslint-plugin-prettier": "2.1.1", "eslint-plugin-react": "^7.2.1", - "flow-bin": "^0.54.0", + "flow-bin": "^0.56.0", "jest": "^21", "mock-fs": "^4.4.1", "prettier": "1.7.0",