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

Typescript definition is wrong #7315

Closed
EternalChildren opened this issue Sep 11, 2019 · 11 comments
Closed

Typescript definition is wrong #7315

EternalChildren opened this issue Sep 11, 2019 · 11 comments
Assignees

Comments

@EternalChildren
Copy link

Current behaviour

image
'initialRouteName' does not exist in type 'NavigationBottomTabOptions'

Expected behaviour

no error

Your Environment

software version
ios or android ios
react-native 0.61.0
react-navigation-tabs 2.4.1
node 10.16.0
npm or yarn 1.17.0
@EternalChildren
Copy link
Author

Who can tell me the reason ? this lib is written by typescript. so the definition is auto generate ?

@xiaoqiang1999
Copy link

I have this problem too.
My version: 2.4.2.

@satya164
Copy link
Member

Please try the latest version

@EternalChildren
Copy link
Author

@satya164 the latest version don't solve completely.
image
tabBarOptions still can't be recognized.

@satya164 satya164 reopened this Sep 14, 2019
@jakst
Copy link

jakst commented Sep 17, 2019

There are more props that exist in the source code but not in types.

So far I've had problems with tabBarComponent, tabBarOptions and lazy on both createBottomTabNavigator and createMaterialTopTabNavigator. swipeEnabled also seems to be missing from createMaterialTopTabNavigator.

Autocompleting on config object of createMaterialTopTabNavigator or createBottomTabNavigator only gives the following suggestions:

backBehavior
defaultNavigationOptions
initialRouteName
initialRouteParams
navigationOptions
order
paths
resetOnBlur

As you can see, something seems to be very broken with the types on both tab creators.

Version: [email protected]
Example:

const BottomNavigator = createBottomTabNavigator(tabs, {
  tabBarComponent: BottomTabComponent
})

Argument of type '{ tabBarComponent: ({ getLabelText, jumpTo }: Props) => Element; }' is not assignable to parameter of type 'CreateNavigatorConfig<{}, NavigationTabRouterConfig, Partial, NavigationTabProp<NavigationRoute, any>>'.
Object literal may only specify known properties, and 'tabBarComponent' does not exist in type 'CreateNavigatorConfig<{}, NavigationTabRouterConfig, Partial, NavigationTabProp<NavigationRoute, any>>'.

@satya164 satya164 self-assigned this Sep 17, 2019
@thepost
Copy link

thepost commented Sep 17, 2019

I am also having this issue in the latest version. Detailed in issue #6308.

satya164 referenced this issue in react-navigation/tabs Sep 17, 2019

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@EternalChildren
Copy link
Author

It's still have some problems. the error picture is in issue #6308 (comment)

@EternalChildren
Copy link
Author

EternalChildren commented Sep 18, 2019

The generated Navigator is also not right.

const Home = (props: NavigationProps) => {
  const { navigation } = props;

  return (
    <SafeAreaView>
      <Navigator navigation={navigation} />  // exist error
    </SafeAreaView>
  );
};
Home.router = Navigator.router;  // exist error
  • first error:
    2322: Type '{ navigation: NavigationScreenProp<NavigationRoute<{}>, NavigationParams>; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'. Property 'navigation' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'.
  • second error:
    2339: Property 'router' does not exist on type 'ComponentType<{}>'. Property 'router' does not exist on type 'ComponentClass<{}, any>'.
    @satya164

@satya164 satya164 reopened this Sep 18, 2019
@zihe-xu
Copy link

zihe-xu commented Sep 19, 2019

typeof createBottomTabNavigator // React.ComponentType<{}>;

However, createAppContainer requires a parameter of type NavigationNavigator

const BottomTabNavigator = createBottomTabNavigator({
  user: UserPage,
  classify: ClassifyPage,
});

export default createAppContainer(BottomTabNavigator); // error

Parameters of type "ComponentType<{}>" cannot be assigned to parameters of type "NavigationNavigator<unknown, unknown>".
You cannot assign type "ComponentClass<{}, any>" to type "NavigationNavigator<unknown, unknown>".
Unable to assign type "ComponentClass<{}, any>" to type "ComponentClass<NavigationNavigatorProps<unknown, {}>, any> & {router: NavigationRouter<unknown, {}>; NavigationOptions? : unknown; } ".
Property 'router' is missing in type 'ComponentClass<{}, any>' but required in type '{router: NavigationRouter<unknown, {}>; NavigationOptions? : unknown; } 'ts (2345).

@satya164

@satya164 satya164 transferred this issue from react-navigation/tabs Feb 24, 2020
@jshowacre
Copy link

Still having this issue with v5...

@github-actions
Copy link

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

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

No branches or pull requests

7 participants