mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #22465 from unindented/redux-injectable-store
Add types for redux-injectable-store 1.0
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for redux-injectable-store 1.0
|
||||
// Project: https://github.com/lelandrichardson/redux-injectable-store#readme
|
||||
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Reducer, Store, StoreEnhancer } from "redux";
|
||||
|
||||
export interface InjectableStore<S> extends Store<S> {
|
||||
inject(namespace: string, reducer: Reducer<any>): void;
|
||||
injectAll(reducers: { [key: string]: Reducer<any> }): void;
|
||||
clearReducers(): void;
|
||||
}
|
||||
|
||||
export type WrapReducer<S> = (reducer: Reducer<S>) => Reducer<S>;
|
||||
|
||||
export interface InjectableStoreCreator {
|
||||
<S>(
|
||||
enhancer?: StoreEnhancer<S>,
|
||||
wrapReducer?: WrapReducer<S>
|
||||
): InjectableStore<S>;
|
||||
<S>(
|
||||
preloadedState: S,
|
||||
enhancer?: StoreEnhancer<S>,
|
||||
wrapReducer?: WrapReducer<S>
|
||||
): InjectableStore<S>;
|
||||
}
|
||||
|
||||
export const createInjectableStore: InjectableStoreCreator;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { createInjectableStore } from "redux-injectable-store";
|
||||
import { applyMiddleware, compose, AnyAction, Middleware } from "redux";
|
||||
|
||||
interface State {
|
||||
foo: string;
|
||||
bar?: string;
|
||||
baz?: string;
|
||||
}
|
||||
|
||||
const initialState: State = { foo: "bar" };
|
||||
|
||||
const middleware: Middleware[] = [];
|
||||
const enhancer = applyMiddleware(...middleware);
|
||||
const store = createInjectableStore<State>(initialState, enhancer);
|
||||
const anotherStore = createInjectableStore<State>(initialState, enhancer, reducer => reducer);
|
||||
|
||||
const dummyReducer = (state: string) => state;
|
||||
|
||||
store.inject("foo", dummyReducer);
|
||||
|
||||
anotherStore.injectAll({
|
||||
bar: dummyReducer,
|
||||
baz: dummyReducer
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-injectable-store-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user