Fix typings for inferno-redux Provider component #1495
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
This PR fixes some typing issues encountered when using
inferno
andinferno-redux
in TypeScript environments.The first fix fixes a typing issue that occurs when the root reducer function's second argument is not
AnyAction
. PreviouslyProvider
will reject any ReduxStore<S, A>
whenA
is notAnyAction
unless it has been type casted as such. This fix was mostly copied from how@types/react-redux
handles it.The second fix fixes a type intersection issue caused by this interface
inferno/packages/inferno-redux/src/components/Provider.ts
Lines 16 to 19 in deccbe5
being passed here (aliased as
P
):inferno/packages/inferno/src/core/component.ts
Lines 120 to 122 in deccbe5
This leads to the type of
props.children
to be:Types like
string & VNode
andtrue & VNode
is likely incorrect. I have been unable to determine whyVNode
was given as the type forProps['children']
, but it seems to be an error and I've changed this toInfernoNode
.The last fix manually specifies the type of
Provider#render()
as a workaround for #1460. Without that line, TypeScript may infer the type and expand theInfernoNode
type alias during.d.ts
generation, leading to an incorrect in-place import forInfernoNodeArray
to be generated.Closes Issue
It closes Issue #1460.