We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an existing function that accepts the navigation object as a prop:
navigation: NavigationProp<ParamListBase, string>,
After upgrading to the latest version of react navigation, this type gives the following typescript error:
Argument of type 'Omit<NavigationProp<RootParamList>, "getState"> & { getState(): Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<...>[]; type: string; stale: false; }> | undefined; }' is not assignable to parameter of type 'NavigationProp<ParamListBase, string>'. Type 'Omit<NavigationProp<RootParamList>, "getState"> & { getState(): Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<...>[]; type: string; stale: false; }> | undefined; }' is not assignable to type 'Omit<NavigationHelpersCommon<ParamListBase, Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<ParamListBase, string>[]; type: string; stale: false; }>>, "getParent">'. The types returned by 'getState()' are incompatible between these types. Type 'Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<ParamListBase, string>[]; type: string; stale: false; }> | undefined' is not assignable to type 'Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<ParamListBase, string>[]; type: string; stale: false; }>'. Type 'undefined' is not assignable to type 'Readonly<{ key: string; index: number; routeNames: string[]; history?: unknown[] | undefined; routes: NavigationRoute<ParamListBase, string>[]; type: string; stale: false; }>'.ts(2345)
I would expect the type here continues to work, or a decent alternative be proposed for how to type a function that accepts the navigation prop.
I can copy the change from inside react navigation in order to work around this issue for now:
navigation: Omit<NavigationProp<ParamListBase, string>, 'getState'> & { getState(): NavigationState | undefined; },
However, I'm wondering if NavigationProp should be updated accordingly?
NavigationProp
https://www.typescriptlang.org/play?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydaiKKEEeBkGgAb1AADkGDoKMw6g1OLQ2AR+LRHAxEM8hKgAEIMQSQfjscWM5ms+qNUAAXxxbEQoAA5AABSawVClThMllsxrAA31PTqgDcwQQnEENDMAFFVvyFpAAGqOCgMaTuUAAXlAACIABIwaAYcBU6JBxS2wTwdwBCPMAAUTpdiDdnsoPvcAEpgskuLr2Wh9KhUwbZcbOPkGYa5ezOfACAAeXlkfmC+2i8V2VCUTjMAB8+dANMUJRK1aN8s4AWYkFQxFQdUgqfz1sVNsa9v6jdrAdAUsgMrn7M31oU9qrh-nW+CKhwzQ8ZC8iCpzmB7BoXzcZjMOwDBLvwsDQOoiQ+vAegiF4QbOq67iCEGSTYkG4AOKg6rCPSkASEGQQqAA8l8ZDvP2WjLlca7UpArjSHgoBOJ+zLDlg+goAgiDQsIlz-hI0auKIhj4vMjAsGwXDcEEJRAA
The text was updated successfully, but these errors were encountered:
@satya164 what do you think?
Sorry, something went wrong.
Yeah we seem to be getting this too. Have done the same as @bhandanyan-nomad but definitely doesn't feel like the right thing to be doing!
No branches or pull requests
Current behavior
I have an existing function that accepts the navigation object as a prop:
After upgrading to the latest version of react navigation, this type gives the following typescript error:
Expected behavior
I would expect the type here continues to work, or a decent alternative be proposed for how to type a function that accepts the navigation prop.
I can copy the change from inside react navigation in order to work around this issue for now:
However, I'm wondering if
NavigationProp
should be updated accordingly?Reproduction
https://www.typescriptlang.org/play?#code/PTAEHUFMBsGMHsC2lQBd5oBYoCoE8AHSAZVgCcBLA1UABWgEM8BzM+AVwDsATAGiwoBnUENANQAd0gAjQRVSQAUCEmYKsTKGYUAbpGF4OY0BoadYKdJMoL+gzAzIoz3UNEiPOofEVKVqAHSKymAAmkYI7NCuqGqcANag8ABmIjQUXrFOKBJMggBcISGgoAC0oACCbvCwDKgU8JkY7p7ehCTkVDQS2E6gnPCxGcwmZqDSTgzxxWWVoASMFmgYkAAeRJTInN3ymj4d-jSCeNsMq-wuoPaOltigAKoASgAywhK7SbGQZIIz5VWCFzSeCrZagNYbChbHaxUDcCjJZLfSDbExIAgUdxkUBIursJzCFJtXydaiKKEEeBkGgAb1AADkGDoKMw6g1OLQ2AR+LRHAxEM8hKgAEIMQSQfjscWM5ms+qNUAAXxxbEQoAA5AABSawVClThMllsxrAA31PTqgDcwQQnEENDMAFFVvyFpAAGqOCgMaTuUAAXlAACIABIwaAYcBU6JBxS2wTwdwBCPMAAUTpdiDdnsoPvcAEpgskuLr2Wh9KhUwbZcbOPkGYa5ezOfACAAeXlkfmC+2i8V2VCUTjMAB8+dANMUJRK1aN8s4AWYkFQxFQdUgqfz1sVNsa9v6jdrAdAUsgMrn7M31oU9qrh-nW+CKhwzQ8ZC8iCpzmB7BoXzcZjMOwDBLvwsDQOoiQ+vAegiF4QbOq67iCEGSTYkG4AOKg6rCPSkASEGQQqAA8l8ZDvP2WjLlca7UpArjSHgoBOJ+zLDlg+goAgiDQsIlz-hI0auKIhj4vMjAsGwXDcEEJRAA
Platform
Packages
Environment
The text was updated successfully, but these errors were encountered: