react-navigation-helpers icon indicating copy to clipboard operation
react-navigation-helpers copied to clipboard

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

Open tconroy opened this issue 1 year ago • 2 comments

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
  });
};

tconroy avatar Jun 25 '23 17:06 tconroy