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

[ts] v5 native stack does not throw error when using unknown props on it #809

Closed
sbalay opened this issue Feb 11, 2021 · 2 comments · Fixed by #810
Closed

[ts] v5 native stack does not throw error when using unknown props on it #809

sbalay opened this issue Feb 11, 2021 · 2 comments · Fixed by #810

Comments

@sbalay
Copy link

sbalay commented Feb 11, 2021

Description

The type of NativeStackNavigatorProps is not narrowed down to only known props and does not generate a ts error when unknown props are specified to the Navigator component:

const RootStack = createNativeStackNavigator()

RootNavigator = () => {
  return (
    <RootStack.Navigator whatever unknownProp={3}>
      <RootStack.Screen
        name="Splash"
        component={SplashScreen}
      />
  </RootStack.Navigator>

The above code does not throw any ts error, even though whatever and unknownProp are not props of Navigator.

I believe this is caused by NativeStackNavigationConfig which is defined as Record<string, unknown> and then used to build the NativeStackNavigatorProps type.

NativeStackNavigationConfig does not seem to be used anywhere in the codebase, I was going to send a PR just deleting it but I'm not sure about the implications of doing so.

Expected behavior

Navigator throws a ts error when unknown props are specified

Actual behavior

Navigator does not throw a ts error when unknown props are specified

Package versions

  • React: 16.13.1
  • React Native: 0.63.2
  • React Native Screens: 2.16.1
@WoLewicki
Copy link
Member

Can you check if #810 fixes it?

@sbalay
Copy link
Author

sbalay commented Feb 11, 2021

Can you check if #810 fixes it?

Yep!

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

Successfully merging a pull request may close this issue.

2 participants