Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bdec1e5
Updated tests to fix build Closed #95 (#133)
piotrwitek Feb 3, 2019
857d9fd
Adds info import module decleration (#134)
arshadkazmi42 Feb 4, 2019
23ffca5
Updated Recipes section Closed #137
piotrwitek Feb 12, 2019
8f51601
Updated TOC
piotrwitek Feb 12, 2019
af7d940
Updated deps (#139)
piotrwitek Feb 12, 2019
c06d37a
Added example for using context in class component (#141)
binoy14 Feb 14, 2019
33d96b6
Testing epics (#144)
piotrwitek Feb 22, 2019
8c796de
updated deps
piotrwitek Mar 7, 2019
1259b21
added redux-thunk types overload
piotrwitek Mar 7, 2019
d0a05b2
Updated legacy patterns
piotrwitek Mar 7, 2019
5d03b97
ThunkActionType prototype
piotrwitek Mar 7, 2019
342a6ad
fix spelling mistake (#152)
SCKelemen Apr 6, 2019
0ecf245
Updated docs and and example of integration with redux-thunk Resolved…
piotrwitek Apr 6, 2019
c8d35fe
Merge branch 'redux-thunk'
piotrwitek Apr 6, 2019
b5cefb4
Added hyperlinks for better UX
piotrwitek Apr 6, 2019
34fc808
Small updates
piotrwitek Apr 13, 2019
e732b43
Updated playground project and added integration with react-redux-typ…
piotrwitek Apr 13, 2019
3f978be
Added new solution to Connect with `react-redux` to solve validation …
piotrwitek Apr 13, 2019
acd9b20
Added ESLint config section (#158)
piotrwitek Apr 14, 2019
93fc2b8
Refactored playground to use create-react-app (#159)
piotrwitek Apr 14, 2019
cf8a03c
Capitalize file to fix import on POSIX systems (#160)
lordi Apr 15, 2019
05ddc8f
Added prettier to common npm scripts
piotrwitek Apr 18, 2019
0ff885d
Added doctoc
piotrwitek Apr 21, 2019
01bc1df
Updated readme
piotrwitek Apr 21, 2019
0c2afc9
Updated readme with new section about createReducer API
piotrwitek Apr 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added redux-thunk types overload
  • Loading branch information
piotrwitek committed Mar 7, 2019
commit 1259b21ae11e1284f388a47b476d9fcf9522815b
1 change: 1 addition & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// "@src/*": ["src/*"] // will enable import aliases -> import { ... } from '@src/components'
// WARNING: Require to add this to your webpack config -> resolve: { alias: { '@src': PATH_TO_SRC } }
// "redux": ["typings/redux"], // override library types with your alternative type-definitions in typings folder
"redux-thunk": ["typings/redux-thunk"] // override library types with your alternative type-definitions in typings folder
},
"outDir": "dist/", // target for compiled files
"allowSyntheticDefaultImports": true, // no errors with commonjs modules interop
Expand Down
58 changes: 58 additions & 0 deletions playground/typings/redux-thunk/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
Action,
ActionCreatorsMapObject,
AnyAction,
Dispatch,
Middleware,
} from 'redux';

export interface ThunkDispatch<S, E, A extends Action> {
<R>(thunkAction: ThunkAction<R, S, E, A>): R;
<T extends A>(action: T): T;
}

export type ThunkAction<R, S, E, A extends Action> = (
dispatch: ThunkDispatch<S, E, A>,
getState: () => S,
extraArgument: E
) => R;

/**
* Takes a ThunkAction and returns a function signature which matches how it would appear when processed using
* bindActionCreators
*
* @template T ThunkAction to be wrapped
*/
export type ThunkActionDispatch<
T extends (...args: any[]) => ThunkAction<any, any, any, any>
> = (...args: Parameters<T>) => ReturnType<ReturnType<T>>;

export type ThunkMiddleware<
S = {},
A extends Action = AnyAction,
E = undefined
> = Middleware<ThunkDispatch<S, E, A>, S, ThunkDispatch<S, E, A>>;

declare const thunk: ThunkMiddleware & {
withExtraArgument<E>(extraArgument: E): ThunkMiddleware<{}, AnyAction, E>;
};

export default thunk;

/**
* Redux behaviour changed by middleware, so overloads here
*/
declare module 'redux' {
/**
* Overload for bindActionCreators redux function, returns expects responses
* from thunk actions
*/
function bindActionCreators<M extends ActionCreatorsMapObject<any>>(
actionCreators: M,
dispatch: Dispatch
): {
[N in keyof M]: ReturnType<M[N]> extends ThunkAction<any, any, any, any>
? (...args: Parameters<M[N]>) => ReturnType<ReturnType<M[N]>>
: M[N]
};
}