Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

TypeScript typings rely on nonexistent @react-navigation/core libdefs #90

@jakub-astrahit

Description

@jakub-astrahit

Hi, I just installed react-navigation-redux-helpers and am having issues with the TypeScript typings

node_modules/react-navigation-redux-helpers/index.d.ts:9:10 - error TS7016: Could not find a declaration file for module '@react-navigation/core'. '/Users/foo/ui/node_modules/@react-navigation/core/lib/commonjs/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-navigation__core` if it exists or add a new declaration (.d.ts) file containing `declare module '@react-navigation/core';`

9   } from '@react-navigation/core';

Screen Shot 2019-08-07 at 14 25 42

My implementation:

import React from 'react'
import { createStackNavigator, NavigationParams, NavigationRoute, NavigationScreenProp } from 'react-navigation'
import { createReduxContainer } from 'react-navigation-redux-helpers'
import { connect } from 'react-redux'
import { AppState } from './store'

export const screens = strEnum([
    'FOO',
])
export type Screen = keyof typeof screens
export const getDefaultNavigationOptions = ({ navigation }: any) => ({
    header: <Header header={navigation.getParam('header')} />,
})
export const AppNavigator = createStackNavigator(
    {
        [screens.FOO]: {
            screen: FooScreen,
            params: { header: { title: 'Foo.Title' } },
        },
       
    },
    {
        initialRouteName: screens.FOO,
        headerMode: 'float',
        defaultNavigationOptions: getDefaultNavigationOptions,
    },
)

const mapStateToProps = (state: AppState) => ({
    state: state.navigation,
})

const NavContainer: React.FC = () => {
    const Navigator = connect(mapStateToProps)(createReduxContainer(AppNavigator))
    return <Navigator />
}

export default NavContainer

Here is the contents of the node_modules/react-navigation-redux-helpers/index.d.ts file:

declare module 'react-navigation-redux-helpers' {
  import {
    NavigationContainer,
    NavigationEventCallback,
    NavigationEventSubscription,
    NavigationState,
    NavigationDispatch,
    NavigationScreenProp
  } from '@react-navigation/core';
...

Any ideas what's wrong with the typings on the last line? '@react-navigation/core';

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions