1- import type * as React from 'react'
21import type { RouteProp } from '@react-navigation/native'
32import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
4- import type { RouteDef } from '@/constants/types/router'
5- import type { newRoutes as chatNewRoutes , newModalRoutes as chatNewModalRoutes } from '../chat/routes'
6- import type { newRoutes as cryptoNewRoutes , newModalRoutes as cryptoNewModalRoutes } from '../crypto/routes'
7- import type { newRoutes as deviceNewRoutes , newModalRoutes as deviceNewModalRoutes } from '../devices/routes'
8- import type { newRoutes as fsNewRoutes , newModalRoutes as fsNewModalRoutes } from '../fs/routes'
9- import type { newRoutes as gitNewRoutes , newModalRoutes as gitNewModalRoutes } from '../git/routes'
10- import type { newRoutes as loginNewRoutes , newModalRoutes as loginNewModalRoutes } from '../login/routes'
11- import type { newRoutes as peopleNewRoutes , newModalRoutes as peopleNewModalRoutes } from '../people/routes'
12- import type { newRoutes as profileNewRoutes , newModalRoutes as profileNewModalRoutes } from '../profile/routes'
13- import type {
14- newRoutes as settingsNewRoutes ,
15- newModalRoutes as settingsNewModalRoutes ,
16- } from '../settings/routes'
17- import type { newRoutes as signupNewRoutes , newModalRoutes as signupNewModalRoutes } from '../signup/routes'
18- import type { newRoutes as teamsNewRoutes , newModalRoutes as teamsNewModalRoutes } from '../teams/routes'
19- import type { newModalRoutes as walletsNewModalRoutes } from '../wallets/routes'
20- import type { newModalRoutes as incomingShareNewModalRoutes } from '../incoming-share/routes'
3+ import type { routes , modalRoutes , loggedOutRoutes } from './routes'
214
22- type IsUnknown < T > = unknown extends T ? ( [ keyof T ] extends [ never ] ? true : false ) : false
23- type NormalizeParams < T > = IsUnknown < T > extends true ? undefined : T extends object | undefined ? T : undefined
24- type ExtractScreenParams < Screen > =
25- Screen extends React . LazyExoticComponent < infer Inner >
26- ? ExtractScreenParams < Inner >
27- : Screen extends React . ComponentType < infer Props >
28- ? Props extends { route : { params : infer Params } }
29- ? NormalizeParams < Params >
30- : Props extends { route : { params ?: infer Params } }
31- ? NormalizeParams < Params >
32- : undefined
33- : undefined
34- type ExtractRouteParams < Route > = Route extends RouteDef < any , infer Params >
35- ? NormalizeParams < Params >
36- : Route extends { initialParams : infer Params }
37- ? NormalizeParams < Params >
38- : '__routeParams' extends keyof Route
39- ? Route extends { __routeParams ?: infer Params }
40- ? NormalizeParams < Params >
5+ // tsgo bug: StaticParamList is the idiomatic React Navigation equivalent of _ExtractParams,
6+ // but tsgo reports "TS2315: Type 'StaticParamList' is not generic" (works fine with regular tsc).
7+ // Once tsgo fixes re-exported generic type aliases, replace _ExtractParams:
8+ // type _SyntheticConfig = {readonly config: {readonly screens: _AllScreens}}
9+ // export type RootParamList = StaticParamList<_SyntheticConfig> & Tabs & {...}
10+ //
11+ // Similarly, avoid matching on RouteDef<any, infer Params> — tsgo fails to infer Params
12+ // through conditional types in RouteDef's field definitions. Instead, extract params
13+ // directly from the screen function's route prop, which tsgo handles correctly.
14+ type _ExtractParams < T > = {
15+ [ K in keyof T ] : T [ K ] extends { screen : infer U }
16+ ? U extends ( args : infer V ) => any
17+ ? V extends { route : { params : infer W } }
18+ ? W
19+ : undefined
4120 : undefined
42- : Route extends { screen : infer Screen }
43- ? ExtractScreenParams < Screen >
4421 : undefined
45-
46- type _ExtractParams < T > = {
47- [ K in keyof T ] : ExtractRouteParams < T [ K ] >
4822}
4923
5024type Tabs = {
@@ -62,34 +36,10 @@ type Tabs = {
6236 'tabs.walletsTab' : undefined
6337}
6438
65- type _AllScreens = typeof deviceNewRoutes &
66- typeof chatNewRoutes &
67- typeof cryptoNewRoutes &
68- typeof peopleNewRoutes &
69- typeof profileNewRoutes &
70- typeof fsNewRoutes &
71- typeof settingsNewRoutes &
72- typeof teamsNewRoutes &
73- typeof gitNewRoutes &
74- typeof chatNewModalRoutes &
75- typeof cryptoNewModalRoutes &
76- typeof deviceNewModalRoutes &
77- typeof fsNewModalRoutes &
78- typeof gitNewModalRoutes &
79- typeof loginNewModalRoutes &
80- typeof peopleNewModalRoutes &
81- typeof profileNewModalRoutes &
82- typeof settingsNewModalRoutes &
83- typeof signupNewModalRoutes &
84- typeof teamsNewModalRoutes &
85- typeof walletsNewModalRoutes &
86- typeof incomingShareNewModalRoutes &
87- typeof loginNewRoutes &
88- typeof signupNewRoutes
39+ type _AllScreens = typeof routes & typeof modalRoutes & typeof loggedOutRoutes
8940
90- type KeybaseRootParamList = _ExtractParams < _AllScreens > &
41+ export type RootParamList = _ExtractParams < _AllScreens > &
9142 Tabs & { loading : undefined ; loggedOut : undefined ; loggedIn : undefined }
92- export type RootParamList = KeybaseRootParamList
9343
9444export type RouteKeys = keyof RootParamList
9545export type NoParamRouteKeys = {
0 commit comments