From 4ef6092c147747732635948110e69ac62932c3d4 Mon Sep 17 00:00:00 2001 From: mmkal Date: Sun, 24 Sep 2017 15:22:55 -0400 Subject: [PATCH] use mapped type for combineReducers Enforces using valid property names for reducers, and having the reducers return valid objects. Uses TypeScript 2.x feature https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-types --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index ced1559263..2c2cadcc0c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -59,8 +59,8 @@ export type Reducer = (state: S, action: AnyAction) => S; /** * Object whose values correspond to different reducer functions. */ -export interface ReducersMapObject { - [key: string]: Reducer; +export type ReducersMapObject = { + [key in keyof TState]: Reducer; } /** @@ -81,7 +81,7 @@ export interface ReducersMapObject { * @returns A reducer function that invokes every reducer inside the passed * object, and builds a state object with the same shape. */ -export function combineReducers(reducers: ReducersMapObject): Reducer; +export function combineReducers(reducers: ReducersMapObject): Reducer; /* store */