From 4464cbbfe725bfc191006e41cbe634dc87b8baaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilker=20G=C3=BCller?= <694940+Sly777@users.noreply.github.com> Date: Sat, 6 Oct 2018 00:01:34 +0200 Subject: [PATCH] react-navigation: Updated withNavigation HOC for suppressing prop requirement (#29208) ## Why? Typescript requires assign of `navigation` on Component that is created with `withNavigation` HOC. But it comes with that function so it shouldn't require that property. ## Example ```typescript // // on the current version, this will give an error. // with this PR, it will work. // interface IHelloProps extends Partial { hello: boolean; } const HelloBox: SFC = ({ navigation, hello }) => ( navigation.navigate('TEST', { hello })}> Hello ; ); export default withNavigation(HelloBox); ``` ---- Please fill in this template. - [X] Use a meaningful title for the pull request. Include the name of the package modified. - [X] Test the change in your own code. (Compile and run.) - [x] Add or edit tests to reflect the change. (Run with `npm test`.) - [x] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). - [X] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [X] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present). Select one of these and delete the others: If adding a new definition: - [ ] The package does not already provide its own types, or cannot have its `.d.ts` files generated via `--declaration` - [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package. - [ ] Create it with `dts-gen --dt`, not by basing it on an existing project. - [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, `strictNullChecks`, and `strictFunctionTypes` set to `true`. If changing an existing definition: - [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <> - [ ] Increase the version number in the header if appropriate. - [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "dtslint/dt.json" }`. If removing a declaration: - [ ] If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.) - [ ] Delete the package's directory. - [ ] Add it to `notNeededPackages.json`. --- types/react-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 80b54d23a2..1bdf43bc35 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -1254,7 +1254,7 @@ export function withNavigation( - Component: React.ComponentType>, + Component: React.ComponentType)>, ): React.ComponentType>> }>; export interface NavigationFocusInjectedProps

extends NavigationInjectedProps

{