Commit Graph

16 Commits

Author SHA1 Message Date
Marco Buono
b7486f2c4d react-redux: fix dispatchToProps as object
This fixes the resulting wrapped component type returned by
the connect HOC when the `dispatchToProps` argument is an object. (Fixes
issue #18955)

Previously we were using `MapDispatchToPropsObject` but that doesn't
work with `Omit<T, K>`, so dispatch props were being preserved on the
resulting object. I've replaced that with `TDispatchProps` instead.

I've added test code by @horiuchi, adapted from:
https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18955
2017-08-18 21:06:54 -03:00
Daniel Rosenwasser
b71c0e48ac Merge pull request #18984 from coreh/patch-1
react-redux: Make dispatch property optional in DispatchProp<S>
2017-08-16 13:25:05 -07:00
Marco Buono
53266428eb react-redux: Add test for optional dispatch prop 2017-08-15 14:53:42 -03:00
Frank Tan
eaea12959d [react-redux] Do not mark ownProps as optional
According to docs, "it's always legal to provide a callback that accepts fewer arguments": https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#optional-parameters-in-callbacks

Morever, react-redux docs say that ownProps will have a value when it is specified as a callback argument: https://github.com/reactjs/react-redux/blob/master/docs/api.md#the-arity-of-mapstatetoprops-and-mapdispatchtoprops-determines-whether-they-receive-ownprops
2017-08-15 10:13:01 -04:00
Curtis Layne
9a3c424109 [react-redux] Update types for react-redux (#18510)
The types were failing to remove props they injected from requirements
for the parents rendering them. By using Omit we can omit props that are
injected from the connect component so that we don't get errors during
parent rendering.

All of this is done through type inference so that end users don't have
to be aware that this is happening.
2017-08-14 12:09:47 -07:00
Tanguy Krotoff
573083a518 Replace React.Component<(any|void|\{\}|null)> by React.Component
+ many manual adjustments
2017-06-21 09:48:37 +02:00
Tanguy Krotoff
ea9de8a518 Replace React.Component<(.*), (any|void|\{\}|null)> by React.Component<$1>
+ many manual adjustments
2017-06-19 13:35:50 +02:00
Blake Embrey
a6087cff80 Explicitly enable inference with connect() 2017-06-14 18:54:34 -04:00
Blake Embrey
f527af6ed3 Annotate react-redux more explicitly 2017-06-05 16:09:30 -04:00
Nathan Shively-Sanders
163f4438df Fix weak type errors (#16845)
* Fix first round of weak type errors

Done through griddle-react

* 95% done with weak type fixes

* Fix last couple of weak type errors

* Remove some lint from mithril tests

* mithril's Lifecycle is not a weak type any more

Restore the Lifecycle constraints in the rest of the definitions.

* Fix react-redux tests after #16652 broke them

* Remove package-lock.json
2017-06-04 22:03:03 -07:00
Blake Embrey
2bc7feeb48 [react-redux] Expose dispatch with props (#16652) 2017-06-02 07:19:38 -07:00
Thomas Hasner
10a204d02d Add overloads to account for mergeProps (#16024)
* Add overloads to account for `mergeProps`

This also provides better typings for users of `strictNullChecks`

* more overloads and tests

* accept `null | undefined`

* allow placeholder typings

* tests

* one `ComponentDecorator`

* tests

* no keyword
2017-04-26 11:52:32 -07:00
Yui
a34f72687e Merge pull request #15993 from DefinitelyTyped/react-redux
react-redux: Remove test which does not compile in TypeScript 2.3
2017-04-25 14:54:20 -07:00
Andy Hanson
6cf0462819 react-redux: Remove test which does not compile in TypeScript 2.3 2017-04-19 10:23:24 -07:00
Thomas Hasner
52371a816d ComponentDecorator input accepts TOwnProps 2017-04-17 21:53:18 -04:00
Andy Hanson
354cec620d Move all packages to a types directory 2017-03-24 14:27:52 -07:00