I have an Error screen that needs to know the error number and a description to display the error and I can't figure out how to tell TS which types are my Error screen custom params. I'm calling my Error screen this way.
navigation.dispatch( StackActions.replace('Error', { statusCode: 400, description: 'Error description', }), );
This is my Error screen component. TS complains in route.params
export default function ErrorScreen({ route, navigation }: RootStackScreenProps<'Error'>) { const { statusCode, description } = route.params; <-- TS error here // @ts-ignore const { setClientURL } = appState(({ setClientURL }) => ({ setClientURL, }));
TS2339: Property 'description' does not exist on type 'Readonly {key: string; index: number; routeNames: string[]; history?: unknown[]| undefined; routes: NavigationRoute []; type: string; stale: false;}>> | undefined>'.
How can I tell TS that for my Error screen route.params can have statusCode and description primitives?