types-redux-orm
Typescript types for Redux Orm
Important
It's an alpha version of types I currently use in one of my projects. They will be updated as I proceed with the project. No backward compatibility guaranteed.
Roadmap
01/13/18 - Beta release
02/03/18 - Stable release and merge into DefinitelyTyped
Install
npm install types-redux-orm
Modify your tsconfig.json as following:
...
"typeRoots": [
"./node_modules/types-redux-orm",
"./node_modules/@types"
],
...
Recipes
Model
<ITestStateItem IFetchIndicatorState> static modelName = 'Test' static fields = test: isFetching: id: // core data which we do not have defaults for // optional data we provide defaults for // id attr is added automatically by redux-orm therefore we have IORMId interface interface ITestORMModels Test: typeof Test const orm = <ITestORMState>ormregister<ITestORMModels>Test
Reducer
interface ITestDTO test: string const reducerAddItem = state: ITestORMState action: ActionMeta<ITestDTO any>: { const session = orm sessionTestupsert<ITestStateItem>actionpayload return sessionstate}
Selector
interface ITestDisplayItem test: stringtype ITestDisplayItemList = ITestDisplayItem const makeGetTestDisplayList = { const ormSelector = createSelectorORM<ITestORMState>orm sessionTest all<ITestStateItem IFetchIndicatorState> } return createSelector<IRootState ITestORMState ITestDisplayItemList> test ormSelector }