From ba0a0a8a4e97b7b7066d628a58173c34c88dcdef Mon Sep 17 00:00:00 2001 From: Niels de Bruin Date: Wed, 22 Dec 2021 18:25:08 +0100 Subject: [PATCH] Add generic for value types --- src/index.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index b0d227b..7c33f93 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -4,25 +4,25 @@ export type FieldName = string export type FieldPattern = FieldName | RegExp | (FieldName | RegExp)[] -export type UpdatesByName = { - [FieldName: string]: (value: any, allValues?: Object, prevValues?: Object) => any +export type UpdatesByName = { + [FieldName: string]: (value: any, allValues?: T, prevValues?: T) => any } -export type UpdatesForAll = ( - value: any, +export type UpdatesForAll = ( + value: T[keyof T], field: string, - allValues?: Object, - prevValues?: Object, + allValues?: T, + prevValues?: T ) => { [FieldName: string]: any } -export type Updates = UpdatesByName | UpdatesForAll +export type Updates = UpdatesByName | UpdatesForAll -export type Calculation = { - field: FieldPattern, - updates: Updates, - isEqual?: (a: any, b: any) => boolean, +export type Calculation = { + field: FieldPattern + updates: Updates + isEqual?: (a: any, b: any) => boolean } -export default function createDecorator( - ...calculations: Calculation[] -): Decorator +export default function createDecorator( + ...calculations: Calculation[] +): Decorator