How to overwrite global RootParamList in react-navigation v6

Viewed 541

In the upgrade guide to react-navigation v6:

https://reactnavigation.org/docs/upgrading-from-5.x/#ability-to-specify-a-type-for-root-navigator-when-using-typescript

it states that you can use

declare global {
  namespace ReactNavigation {
    interface RootParamList extends RootStackParamList {}
  }
}

somewhere in your code to set the RootParamList globally for all hooks etc.

However, when I try to include the snippet and set my param list all I get is

Duplicate identifier 'RootParamList'.ts(2300)
types.d.ts(5, 19): 'RootParamList' was also declared here

Obviously, the type is already declared and I am trying to overwrite it but this does not seem to be possible.

Any ideas how to overwrite without resulting in a type error?

0 Answers
Related