Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow issues with RN 0.46.1 #2215

Closed
Palisand opened this issue Jul 21, 2017 · 20 comments
Closed

Flow issues with RN 0.46.1 #2215

Palisand opened this issue Jul 21, 2017 · 20 comments
Labels

Comments

@Palisand
Copy link

Palisand commented Jul 21, 2017

This probably has to do with this, and the fact that I'm using RN 0.46.1 instead of 0.45.1 (from package.json).

Current Behavior

Flow issues:

node_modules/react-navigation/src/TypeDefinition.js:7
  7:   type ViewProps,
            ^^^^^^^^^ Named import from module `react-native`. This module has no named export called `ViewProps`.

node_modules/react-navigation/src/TypeDefinition.js:8
  8:   type TextProps,
            ^^^^^^^^^ Named import from module `react-native`. This module has no named export called `TextProps`.

node_modules/react-navigation/src/TypeDefinition.js:9
  9:   type StyleDefinition,
            ^^^^^^^^^^^^^^^ Named import from module `react-native`. This module has no named export called `StyleDefinition`.

node_modules/react-navigation/src/TypeDefinition.js:10
 10:   type AnimatedViewStylePropTypes,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `react-native`. This module has no named export called `AnimatedViewStylePropTypes`.

node_modules/react-navigation/src/TypeDefinition.js:448
448:   easing?: (t?: number) => number,
                     ^^^^^^ undefined. This type is incompatible with the expected param type of
227:   ): (t: number) => number {
              ^^^^^^ number. See: node_modules/react-native/Libraries/Animated/src/Easing.js:227

node_modules/react-navigation/src/TypeDefinition.js:448
448:   easing?: (t?: number) => number,
                     ^^^^^^ undefined. This type is incompatible with the expected param type of
237:   ): (t: number) => number {
              ^^^^^^ number. See: node_modules/react-native/Libraries/Animated/src/Easing.js:237

node_modules/react-navigation/src/TypeDefinition.js:448
448:   easing?: (t?: number) => number,
                     ^^^^^^ undefined. This type is incompatible with the expected param type of
246:   ): (t: number) => number {
              ^^^^^^ number. See: node_modules/react-native/Libraries/Animated/src/Easing.js:246

node_modules/react-navigation/src/TypeDefinition.js:448
448:   easing?: (t?: number) => number,
                     ^^^^^^ undefined. This type is incompatible with the expected param type of
257:   ): (t: number) => number {
              ^^^^^^ number. See: node_modules/react-native/Libraries/Animated/src/Easing.js:257

node_modules/react-navigation/src/createNavigationContainer.js:5
  5: import { BackHandler, Linking } from './PlatformHelpers';
                                          ^^^^^^^^^^^^^^^^^^^ ./PlatformHelpers. Required module not found

node_modules/react-navigation/src/views/CardStack/CardStackStyleInterpolator.js:3
  3: import { I18nManager, type AnimatedViewStylePropTypes } from 'react-native';
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `react-native`. This module has no named export called `AnimatedViewStylePropTypes`.

node_modules/react-navigation/src/views/Header/Header.js:110
110:       <HeaderTitle
           ^ React element `HeaderTitle`
 20: const HeaderTitle = ({ style, ...rest }: Props) =>
                                              ^^^^^ property `children`. Property not found in. See: node_modules/react-navigation/src/views/Header/HeaderTitle.js:20
110:       <HeaderTitle
           ^ props of React element `HeaderTitle`

node_modules/react-navigation/src/views/Header/Header.js:111
111:         onLayout={onLayoutIOS}
                       ^^^^^^^^^^^ arrow function. Could not decide which case to select
111:         onLayout={onLayoutIOS}
                       ^^^^^^^^^^^ conditional
  Case 1 may work:
  111:         onLayout={onLayoutIOS}
                         ^^^^^^^^^^^ arrow function
  But if it doesn't, case 2 looks promising too:
  111:         onLayout={onLayoutIOS}
                         ^^^^^^^^^^^ identifier `undefined`
  Please provide additional annotation(s) to determine whether case 1 works (or consider merging it with case 2):
   99:         ? (e: LayoutEvent) => {
                                    ^ return

node_modules/react-navigation/src/views/Header/HeaderStyleInterpolator.js:6
  6:   type StyleDefinition,
            ^^^^^^^^^^^^^^^ Named import from module `react-native`. This module has no named export called `StyleDefinition`.

node_modules/react-navigation/src/views/Header/HeaderStyleInterpolator.js:7
  7:   type AnimatedViewStylePropTypes,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `react-native`. This module has no named export called `AnimatedViewStylePropTypes`.

Expected Behavior

No flow issues.

Your Environment

software version
react-navigation 1.0.0-beta.12 (git+https://github.com/react-community/react-navigation.git#99cd4604b402852765592aa52b00e4d4933518e0)
react-native 0.46.1
@richardgirges
Copy link

I was able to reproduce this as well on RN 0.46.1 with "react-navigation": "^1.0.0-beta.11"

@Nhacsam
Copy link

Nhacsam commented Jul 29, 2017

Did you find any workaround to suppress these errors ?

@Palisand
Copy link
Author

Palisand commented Jul 29, 2017

@Nhacsam You can add .*/node_modules/react-navigation/.* under [ignore] in your .flowconfig. You will still have errors, but not as many. To reduce them further, you can try adding react-navigation.js to your flow-typed/npm directory (see Library Definitions).

Doing this defeats the point of flow though, unless you recreate the modules in the library definition. But, ain't nobody got time for that. We'll just have to be patient and wait for the next release.

@radko93
Copy link
Sponsor

radko93 commented Aug 3, 2017

@Palisand When I add react-navigation to ignore I get

react-navigation. Required module not found

@jedrichards
Copy link

jedrichards commented Aug 5, 2017

Can someone enlighten me why this library is publishing code to npm that is causing everyone's flow setup to report loads of weird errors from outside of their app code? Shouldn't they wait until it isn't broken to publish flow enabled code to npm? Or can/should this be solved in user .flowconfig files? I'm confused ...

@radko93
Copy link
Sponsor

radko93 commented Aug 5, 2017

Beta 12 is not yet published to npm.

@xareelee
Copy link

xareelee commented Sep 9, 2017

Still got this issue with RN 0.47.2 and flow 0.49.1.

src/Navigator.js:4
  4: } from 'react-navigation';
            ^^^^^^^^^^^^^^^^^^ react-navigation. Required module not found

src/Navigator.js:11
 11: } from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator';
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ react-navigation/src/views/CardStack/CardStackStyleInterpolator. Required module not found

src/container/DrawerContainer.js:5
  5: } from 'react-navigation';
            ^^^^^^^^^^^^^^^^^^ react-navigation. Required module not found

src/container/flowtypes.js:7
  7: } from 'react-navigation/src/TypeDefinition';
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ react-navigation/src/TypeDefinition. Required module not found

.flowconfig

[ignore]
.*/node_modules/react-navigation/.*

[include]
.*/node_modules/react-navigation/src/TypeDefinition.js
.*/node_modules/react-navigation/src/react-navigation.js

@Palisand
Copy link
Author

Palisand commented Sep 9, 2017

I got real tired of seeing flow errors for third-party modules and the issues that come with [ignore]ing them...

flow-result-checker by jbreckel
flow-error-suppressor by yours truly

Pick your poison.

@Ashoat
Copy link
Member

Ashoat commented Sep 11, 2017

Unfortunately, react-navigation has had tons of Flow errors for a long time now. I got it all fixed up in #2094, and those who are interested can use my forked version of react-navigation here. However, at this point it's a few months outdated (though it does work with the latest react-native/flow version with no flow errors).

Anyways, the aforementioned PR didn't get any attention from @skevy, who is apparently the only person who is trusted to accept PRs in this repo these days. As a result it languished and I ended up abandoning it.

I would be willing to make a new PR (or set of PRs) getting this repo back to a healthy state vis-a-vis Flow, but I'd need some sort of assurance that my PR wouldn't just languish again.

cc @matthamil, @satya164

Does anybody on the react-navigation team still care about Flow?

@skovhus
Copy link

skovhus commented Sep 19, 2017

Does anybody on the react-navigation team still care about Flow?

At least a lot of users do. So I would like to see some smaller PRs based on #2094. Hopefully some of the new maintainers have time to review it.

@Palisand
Copy link
Author

Palisand commented Sep 19, 2017

For those going the down I-don't-got-time-for-this route, this PR adds silence support for flow!

@Ashoat
Copy link
Member

Ashoat commented Sep 20, 2017

New PR: #2619

Let's hope this one gets reviewed :)

@Ashoat
Copy link
Member

Ashoat commented Sep 20, 2017

The PR should be working, so if anybody wants to give it a try:

npm install git+https://git@github.com/ashoat/react-navigation.git#fixflow

You'll likely see a bunch of new errors when you run Flow, which is probably a good sign! Make sure you remove react-navigation from your .flowconfig's [ignore] list!

@Ashoat
Copy link
Member

Ashoat commented Sep 25, 2017

The PR has been merged! You can get it by using the master version:

npm install git+https://git@github.com/react-community/react-navigation.git

This issue can be closed as soon as a new version of the react-navigation NPM package is cut.

@Palisand
Copy link
Author

@Ashoat Ok so I'll close this when 1.0.0-beta.12 is out on npm. Feel free to do the honors yourself though.

@Ashoat
Copy link
Member

Ashoat commented Sep 25, 2017

1.0.0-beta.12 is already out:

# npm view react-navigation
{ name: 'react-navigation',
  description: 'React Navigation',
  'dist-tags': { latest: '1.0.0-beta.11', next: '1.0.0-beta.12' },
  versions:
   [ '0.0.0',
     '1.0.0-beta.1',
     '1.0.0-beta.2',
     '1.0.0-beta.3',
     '1.0.0-beta.4',
     '1.0.0-beta.5',
     '1.0.0-beta.6',
     '1.0.0-beta.7',
     '1.0.0-beta.8',
     '1.0.0-beta.9',
     '1.0.0-beta.10',
     '1.0.0-beta.11',
     '1.0.0-beta.12' ],
  maintainers:
   [ 'ericvicenti <ericvicenti@gmail.com>',
     'grabbou <grabbou@gmail.com>',
     'satya164 <satyajit.happy@gmail.com>',
     'skevy <adam@sk3vy.com>' ],
  time:
   { modified: '2017-09-16T05:27:30.061Z',
     created: '2016-04-05T21:37:35.098Z',
     '0.0.0': '2016-04-05T21:37:35.098Z',
     '1.0.0-beta.1': '2017-01-26T21:55:34.021Z',
     '1.0.0-beta.2': '2017-02-08T21:18:21.926Z',
     '1.0.0-beta.3': '2017-02-09T14:04:31.757Z',
     '1.0.0-beta.4': '2017-02-16T02:57:50.843Z',
     '1.0.0-beta.5': '2017-02-16T03:11:37.345Z',
     '1.0.0-beta.6': '2017-02-28T02:40:02.600Z',
     '1.0.0-beta.7': '2017-03-11T07:28:51.173Z',
     '1.0.0-beta.8': '2017-04-20T03:33:08.245Z',
     '1.0.0-beta.9': '2017-04-26T22:02:55.087Z',
     '1.0.0-beta.10': '2017-05-19T16:06:36.732Z',
     '1.0.0-beta.11': '2017-05-24T04:54:35.611Z',
     '1.0.0-beta.12': '2017-07-19T20:13:22.710Z' },

It will ostensibly come with 1.0.0-beta.13.

@skovhus
Copy link

skovhus commented Sep 25, 2017

Thanks for working on the Flow definitions @Ashoat.

When using master (with your changes) + flow@0.42.0 (react-native@0.44.3) I do get a lot of errors related to the TypeDefinition.js file. Any ideas what is going on here?

Seems that only some type exports can be read from it. Where NavigationScreenProp is not readable.

node_modules/react-navigation/src/views/Header/HeaderBackButton.js:13
 13: import type { LayoutEvent, TextStyleProp } from '../../TypeDefinition';
                   ^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `LayoutEvent`.

node_modules/react-navigation/src/views/Header/HeaderStyleInterpolator.js:6
  6:   NavigationSceneRendererProps,
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationSceneRendererProps`.

node_modules/react-navigation/src/views/SceneView.js:7
  7:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/SceneView.js:10
 10:   NavigationNavigatorProps,
       ^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationNavigatorProps`.

node_modules/react-navigation/src/views/ScenesReducer.js:8
  8:   NavigationScene,
       ^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationScene`. Did you mean `NavigationState`?

node_modules/react-navigation/src/views/TabView/TabBarBottom.js:11
 11:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/TabView/TabBarIcon.js:9
  9:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/TabView/TabBarTop.js:10
 10:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/TabView/TabView.js:10
 10:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/TabView/TabView.js:15
 15:   NavigationTabScreenOptions,
       ^^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `../../TypeDefinition`. This module has no named export called `NavigationTabScreenOptions`.Did you mean `NavigationScreenOptions`?

node_modules/react-navigation/src/views/Transitioner.js:12
 12:   NavigationLayout,
       ^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationLayout`.

node_modules/react-navigation/src/views/Transitioner.js:13
 13:   NavigationScene,
       ^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationScene`. Did you mean `NavigationState`?

node_modules/react-navigation/src/views/Transitioner.js:16
 16:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/views/Transitioner.js:17
 17:   NavigationTransitionProps,
       ^^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationTransitionProps`.

node_modules/react-navigation/src/views/Transitioner.js:18
 18:   NavigationTransitionSpec,
       ^^^^^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationTransitionSpec`.

node_modules/react-navigation/src/views/withNavigation.js:8
  8:   NavigationScreenProp,
       ^^^^^^^^^^^^^^^^^^^^ Named import from module `../TypeDefinition`. This module has no named export called `NavigationScreenProp`.

node_modules/react-navigation/src/withCachedChildNavigation.js:7
  7: import type { NavigationScreenProp, NavigationAction } from './TypeDefinition';
                   ^^^^^^^^^^^^^^^^^^^^ Named import from module `./TypeDefinition`. This module has no named export called `NavigationScreenProp`.

@skovhus
Copy link

skovhus commented Sep 25, 2017

It seems like the issue mentioned above might be solved when using flow-bin@0.44.1, but I'm stuck with flow@0.42.0 or flow@0.43.1 (due to react-native@0.44.3 compatibility).

@Ashoat
Copy link
Member

Ashoat commented Sep 25, 2017

I'm really not sure why those errors are occurring... it seems pretty clear that TypeDefinition.js has all of those exports. Based on your research I'm guessing the reason is that the code is using some new feature in Flow 0.44, but I'm not sure what that feature might be.

@Palisand
Copy link
Author

#2658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants