diff --git a/example/__typechecks__/common.check.tsx b/example/__typechecks__/common.check.tsx index 5ec8d9a1a3..7fe69fd395 100644 --- a/example/__typechecks__/common.check.tsx +++ b/example/__typechecks__/common.check.tsx @@ -8,11 +8,12 @@ import type { DrawerNavigationOptions, DrawerScreenProps, } from '@react-navigation/drawer'; -import type { - CompositeScreenProps, - NavigationAction, - NavigationHelpers, - NavigatorScreenParams, +import { + type CompositeScreenProps, + type LinkingOptions, + type NavigationAction, + type NavigationHelpers, + type NavigatorScreenParams, } from '@react-navigation/native'; import { createStackNavigator, @@ -498,3 +499,34 @@ const FourthStack = createStackNavigator(); expectTypeOf(FourthStack.Navigator).parameter(0).toMatchTypeOf<{ id: 'MyID'; }>(); + +/** + * Infer correct LinkingOptions + */ +export const linkingOptions: LinkingOptions = { + prefixes: ['reactnavigation://'], + config: { + screens: { + Home: { + screens: { + Feed: { + screens: { + Popular: 'popular', + Latest: 'latest', + // @ts-expect-error "NonExistingRoute" does not exist in the FeedTabParamList + NonExistingRoute: 'non-existing', + }, + }, + Account: 'account', + }, + }, + PostDetails: 'post/:id', + Login: { + path: 'login', + // @ts-expect-error The Login route is not a nested navigator and should not have a screens object + screens: {}, + }, + NotFound: '*', + }, + }, +}; diff --git a/example/src/Screens/NotFound.tsx b/example/src/Screens/NotFound.tsx index 2dca303fb9..8293f23cb4 100644 --- a/example/src/Screens/NotFound.tsx +++ b/example/src/Screens/NotFound.tsx @@ -14,7 +14,7 @@ export const NotFound = ({ 404 Not Found ({route.path})