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

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

Open
jakub-astrahit opened this issue Aug 7, 2019 · 4 comments
Assignees

Comments

@jakub-astrahit
Copy link

jakub-astrahit commented Aug 7, 2019

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';

@Ashoat
Copy link
Member

Ashoat commented Aug 7, 2019

I don't use TypeScript or maintain the typings for it but it looks like you should install the types for the @react-navigation/core

@Ashoat Ashoat closed this as completed Aug 7, 2019
@jakub-astrahit
Copy link
Author

jakub-astrahit commented Aug 7, 2019

@Ashoat I use "@types/react-navigation": "^3.0.8" and it does not work. There's no separate types for core.

@Ashoat Ashoat reopened this Aug 8, 2019
@Ashoat Ashoat changed the title Unable to compile - typings error TypeScript typings rely on nonexistent @react-navigation/core libdefs Aug 8, 2019
@Ashoat
Copy link
Member

Ashoat commented Aug 8, 2019

Okay, I’ve reopened this issue and assigned it to you in the hopes you will do something about it. Again I don’t maintain the TypeScript typings so need somebody else to take the lead

@Ashoat
Copy link
Member

Ashoat commented Aug 8, 2019

A good start would be to tag in the previous maintainers of these typings. Why aren’t they having the same issue? Perhaps you have misconfigured something?

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

No branches or pull requests

2 participants