TypeScript Version: 1.8.0
Code Version: 1.2.0
Code:
I've put all the code in a gist, but the crux is that I want type system support for this line in example.ts:
store.dispatch(thunkedAction(1) as any);
I don't want to have to cast the thunkedAction result to any, but it's the only way I've found to make the compiler happy. It might be any of the following, but I've no idea which:
- Compiler bug
- Compiler feature gap edge case due to combination of
typings globals, typings modules, npm modules, and local .d.ts files
- Insufficiently helpful documentation
- Insufficiently helpful messages
- A developer so frustrated he can no longer think straight
I sincerely hope it's the latter, as then someone will be able to set me straight quickly.
Typings supporting the above code:
declare module "redux-thunk" {
import { Middleware, Dispatch } from 'redux';
export interface Thunk extends Middleware {}
export interface ThunkInterface<R> {
<S>(dispatch: Dispatch<S>, getState?: () => S): R;
}
var thunk: Thunk;
export default thunk;
}
Failing augmentation for redux.Dispatch which seems to override node_modules/redux/index.d.ts for the entire project:
declare module "redux" {
export interface Dispatch<S> {
<R>(thunkAction: ThunkInterface<R>): R;
}
}
Expected behavior:
Per reduxjs/redux#1712, being able to augment redux.Dispatch<S>.
Actual behavior:
Wailing, gnashing of teeth, dumpster fires, sirens in the distance.
TypeScript Version: 1.8.0
Code Version: 1.2.0
Code:
I've put all the code in a gist, but the crux is that I want type system support for this line in
example.ts:store.dispatch(thunkedAction(1) as any);I don't want to have to cast the
thunkedActionresult toany, but it's the only way I've found to make the compiler happy. It might be any of the following, but I've no idea which:typingsglobals,typingsmodules,npmmodules, and local.d.tsfilesI sincerely hope it's the latter, as then someone will be able to set me straight quickly.
Typings supporting the above code:
Failing augmentation for
redux.Dispatchwhich seems to overridenode_modules/redux/index.d.tsfor the entire project:Expected behavior:
Per reduxjs/redux#1712, being able to augment
redux.Dispatch<S>.Actual behavior:
Wailing, gnashing of teeth, dumpster fires, sirens in the distance.