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

Type safety with NavigationService.push() and other methods? #731

Open
tconroy opened this issue Jun 25, 2023 · 2 comments
Open

Type safety with NavigationService.push() and other methods? #731

tconroy opened this issue Jun 25, 2023 · 2 comments
Assignees

Comments

@tconroy
Copy link
Contributor

tconroy commented Jun 25, 2023

Hi!

Wondering if it's possible to get type safety out of the helper methods exposed by this library.

i.e, if you define types in your Navigators like so:

export type FeedStackParamList = {
  Community: {
    name: string;
  };
};

const FeedsStack = createNativeStackNavigator<FeedStackParamList>();

it would be great if we got type safety:

import * as NavigationService from 'react-navigation-helpers';

const navigateToCommunity = () => {
  NavigationService.push("Community", {
    wrongProp: 'foo', // <--- this would error since it's not declared for the route
  });
};
@WrathChaos WrathChaos self-assigned this Jun 26, 2023
@WrathChaos
Copy link
Owner

Nice one! I will working on it

@WrathChaos
Copy link
Owner

Hey @tconroy,

I am still looking for a way to declare or automatically detect the ParamList on the helper. If you have an idea please feel free to share :)

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

No branches or pull requests

2 participants