New to TS and having trouble finding the right typing. I am trying to pass in a partial state object to a helper function I wrote to reset the navigation state. The partial state object looks like this:
const state = { routes: [{ name: 'Home' }, { name: 'Profile', params: {uid: 1} }],};
I am not sure what is the correct way to type it. My helper function looks something like this:
const reset = ( name: string, params: any = {}, key: any = 0, navState?: PartialState<Route>; // <- How to type this? ) = () => { ...}
I tried looking in the types file and found PartialState
or PartialRoute
that seems something I can use, but I'm not sure how to use it. Any help would be appreciated! Have included the typings from the types file below for reference:
export declare type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {key?: string;state?: PartialState<NavigationState>;};export declare type PartialState<State extends NavigationState> = Partial<Omit<State, 'stale' | 'routes'>> & Readonly<{ stale?: true; routes: PartialRoute<Route<State['routeNames'][number]>>[];}>;