feat: Export StackNavigator, StackNavigatorProps and TypedStackNavigator type defs#8460
feat: Export StackNavigator, StackNavigatorProps and TypedStackNavigator type defs#8460jtomaszewski wants to merge 1 commit into
StackNavigator, StackNavigatorProps and TypedStackNavigator type defs#8460Conversation
…avigator` type defs
satya164
left a comment
There was a problem hiding this comment.
Thanks for the PR. Can you also export types for all of the other navigators?
| StackNavigationConfig; | ||
|
|
||
| function StackNavigator({ | ||
| export function StackNavigator({ |
There was a problem hiding this comment.
I think exposing this is confusing (there's no the difference between this and Stack.Navigator to the user, which one should they use). Why do you need it?
| } from '../types'; | ||
|
|
||
| type Props = DefaultNavigatorOptions<StackNavigationOptions> & | ||
| export type Props = DefaultNavigatorOptions<StackNavigationOptions> & |
There was a problem hiding this comment.
I think this shouldn't be exported. You should use React.ComponentProps<typeof Stack.Navigator> or React.ComponentProps<TypedStackNavigator<ParamList>['Navigator']> in this case. Otherwise it lacks type information for params.
| typeof StackNavigator | ||
| >(StackNavigator); | ||
|
|
||
| export type TypedStackNavigator< |
There was a problem hiding this comment.
Can you rename it to StackNavigatorType?
There was a problem hiding this comment.
Should I also rename TypedNavigator to NavigatorType? (That's why I named it TypedStackNavigator, because TypedNavigator already existed.)
There was a problem hiding this comment.
That's internal, so it doesn't matter what we name it. I think TypedNavigator is ok for internal use.
| default as createStackNavigator, | ||
| StackNavigator, | ||
| Props as StackNavigatorProps | ||
| } from './navigators/createStackNavigator'; |
There was a problem hiding this comment.
Can you move the type export to separate export type statement?
e70d751 to
53141a6
Compare
7d64217 to
b1d935c
Compare
|
Closing due to no activity |
|
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. |
(Same as #8233 but rebased from master to main)
Thanks to this, you can easily import and construct a type of a value returned by
createStackNavigator<T>()expression.We would use this because our app is quite complex, and so we extract constructing routes/params/stacks to separate files. We could use this like that: