Skip to content

Commit

Permalink
feat(object): add TS support
Browse files Browse the repository at this point in the history
Thanks @maximelkin for mentoring!
  • Loading branch information
bigslycat committed Mar 3, 2019
1 parent 3e54073 commit 1e395ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,15 @@ export declare var passObjectOf: typeof objectOf;
export declare var objOf: typeof objectOf;
export declare var isObjOf: typeof objectOf;
export declare var passObjOf: typeof objectOf;

type ExtractReturnTypeObject = <T>(
fn: (valueName: string, value: unknown) => ValidationError | T
) => T;

export declare function object<
S extends {
[prop: string]: (valueName: string, value: unknown) => any,
},
>(spec: S): Contract<{
readonly [K in keyof S]: Exclude<ReturnType<S[K]>, ValidationError>
}>;

0 comments on commit 1e395ff

Please sign in to comment.