Add Explicit Props Interface from Store
When I use react-redux
, the TS Compiler always throw an error:
1 | error TS2339: Property '...' does not exist on type 'Readonly<children?: ReactNode; }> & Readonly<{}>'. |
That’s because Connect was not supplying an explicit interface to the container component, so it was confused by the prop that it was trying to pass.
So you can add an explicit interface on child component.
1 | interface PropsFromStore extends React.Props<any> { |
Add Enhancer to Store with TS
When I use an enhancer like:
1 | const enhancer = compose( |
I got an error like:
1 | [ts] Argument of type 'Function' is not assignable to parameter of type 'Func3<{}, {}, {}, {}, StoreEnhancerStoreCreator<{}>>'. |
To resolve this, just:
1 | import { GenericStoreEnhancer } from 'redux' |