Skip to content

Commit

Permalink
optimize recursive type definition (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
nighca authored Apr 27, 2021
1 parent da372fa commit 65bd52a
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ export type ValueOfFieldState<State> = (
: never
)

/** Value Array of given Field. */
// workaround for recursive type reference: https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
// not needed for typescript@3.7+: https://github.com/microsoft/TypeScript/pull/33050
export interface ValueArrayOf<Field> extends Array<ValueOf<Field>> {}

/** Value of object-fields. */
export type ValueOfObjectFields<Fields> = {
[FieldKey in keyof Fields]: ValueOf<Fields[FieldKey]>
Expand All @@ -82,7 +77,7 @@ export type ValueOfObjectFields<Fields> = {
/** Value of array-fields. */
export type ValueOfArrayFields<Fields> = (
Fields extends Array<infer Field>
? ValueArrayOf<Field>
? Array<ValueOf<Field>>
: never
)

Expand Down

0 comments on commit 65bd52a

Please sign in to comment.