Skip to content

Commit

Permalink
Fix Flow types (and update RN version) (react-navigation#2619)
Browse files Browse the repository at this point in the history
* Fix .flowconfig to stop ignoring modules and properly include React Native libraries

Currently, there are numerous ignored libraries that are hiding type errors. Actually, they're causing type errors too. This sort of thing only patches over actual problems, so we have to revert them to get a config we can build upon.

* Update react-native/flow-bin dependencies

We want to have Flow types working with the latest packages.

* Update flow-typed libraries (auto-generated)

* Fix typing of navigation prop used by withNavigation HOC

The current typing is clearly a typo, as it is circular. `NavigationScreenProp` should be used to type the navigation prop

* Fix typing of easing function

What's funny is that I fixed this before in d71ed75. @skevy reintroduced the mistyped function in 9436d03, which didn't trigger any Flow errors because .flowconfig was ignoring the entire react-native package

* Correct typing of View and Text style prop

The current code thinks it can import these, but this isn't true, and was being hidden because the .flowconfig ignored the whole react-native package. There's no easy to type Text and View at the current moment, as far as I can tell. Importing the highly generic `StyleObj` seems like the best bet, and is what I have being using in my projects.

* Import NavigationScreenComponent using full path

* Updating yarn.lock files

* Get rid of library overrides in flow-typed/react-native.js and flow/react-navigation.js

* Add @flow to src/react-navigation.js and make last three params to createNavigator optional

* Make screenProps and navigationOptions optional in NavigationNavigatorProps

* yarn run format

* Readd react-navigation/node_modules ignore to NavigationPlayground's .flowconfig

Realized this line I removed in the first commit is necessary when using npm link/yarn link, which is what the CircleCI build does

* Make all DrawerViewConfig's params optional

Some of these params are marked as optional because they have defaults. However, the only place `DrawerViewConfig` is used is as the input the function that then applies the defaults

* Make all props in NavigationNavigatorProps optional

`NavigationNavigatorProps` is used to type the props of the component that is output by the `StackNavigator`, `TabNavigator`, etc. component factories. This component does not need to have any props specified.

* Make second param to `DrawerNavigator` factory optional

`DrawerNavigator`, just like `TabNavigator` and `StackNavigator`, can be called with just a single argument (ie. omitting the config)

* Upgrade to RN 0.48.4 to address facebook/react-native#15810
  • Loading branch information
Ashoat authored and matthamil committed Sep 25, 2017
1 parent 17c910f commit b759d31
Show file tree
Hide file tree
Showing 72 changed files with 11,359 additions and 8,296 deletions.
13 changes: 3 additions & 10 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
; Ignore templates for 'react-native init'
.*/local-cli/templates/.*

; Ignore the website subdir
.*/node_modules/react-native/website/.*

; Ignore "BUCK" generated dirs
.*/node_modules/react-native/\.buckd/

Expand All @@ -19,20 +16,16 @@
<PROJECT_ROOT>/website/node_modules/react-native/.*
<PROJECT_ROOT>/website/node_modules/fbjs/.*

; Ignore misc packages
.*/node_modules/eslint-.*
.*/node_modules/react-native-tab-view/.*

; Ignore react-native
.*/node_modules/react-native/.*

; Ignore transpiled folders and examples folder
<PROJECT_ROOT>/lib
<PROJECT_ROOT>/lib-rn
<PROJECT_ROOT>/examples

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow

[options]
module.system=haste
Expand Down
17 changes: 8 additions & 9 deletions examples/NavigationPlayground/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js

.*/react-navigation/node_modules/.*

; Additional create-react-native-app ignores

; Ignore duplicate module providers
Expand All @@ -30,24 +32,17 @@
; Ignore react-native-fbads dependency of the expo sdk
.*/node_modules/react-native-fbads/*

.*/node_modules/react-native-tab-view/.*

; Ignore react-native
.*/node_modules/react-native/.*

.*/react-navigation/lib-rn/.*
.*/react-navigation/lib/.*
.*/react-navigation/src/.*
.*/react-navigation/node_modules/.*

.*/react-navigation/examples/ReduxExample/.*
.*/react-navigation/website/.*

[include]

[libs]
../../flow-typed/react-native.js
../../flow/react-navigation.js
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow

[options]
module.system=haste
Expand All @@ -59,6 +54,10 @@ experimental.strict_type_args=true
munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// flow-typed signature: 02359da7064195804e62c853de1fc44e
// flow-typed version: <<STUB>>/babel-jest_v^20.0.1/flow_v0.49.1
// flow-typed signature: e14baf3e1691e7c886f1f41fac30e58e
// flow-typed version: <<STUB>>/babel-jest_v^21.0.0/flow_v0.51.0

/**
* This is an autogenerated libdef stub for:
Expand Down
Loading

0 comments on commit b759d31

Please sign in to comment.