Skip to content

Commit

Permalink
fix: type issue with SliceZone slice_type field
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Feb 19, 2022
1 parent 74b2b53 commit b8b490b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export type IterableElement<TargetIterable> = TargetIterable extends Iterable<
? ElementType
: never;

export type ValueOf<ObjectType extends Record<string, unknown>> =
ObjectType[string];
export type ValueOf<
ObjectType,
ValueType extends keyof ObjectType = keyof ObjectType,
> = ObjectType[ValueType];

type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<
Expand Down Expand Up @@ -141,9 +143,12 @@ export type ModelValue<T extends PrismicModel> =
[P in keyof T["config"]["choices"] as P extends string
? P
: never]: T["config"]["choices"][P] extends prismicT.CustomTypeModelSlice
? CustomTypeModelSliceValue<T["config"]["choices"][P], P>
? CustomTypeModelSliceValue<
T["config"]["choices"][P],
P extends string ? P : string
>
: T["config"]["choices"][P] extends prismicT.CustomTypeModelSharedSlice
? prismicT.SharedSlice<P>
? prismicT.SharedSlice<P extends string ? P : string>
: never;
}>
>
Expand Down

0 comments on commit b8b490b

Please sign in to comment.