Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: treat a custom type model's label property as non-nullable #20

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/model/customType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ type MockCustomTypeModel<
Definition extends
| prismic.CustomTypeModelTab
| prismic.CustomTypeModelDefinition,
> = Definition extends prismic.CustomTypeModelTab
> = (Definition extends prismic.CustomTypeModelTab
? prismic.CustomTypeModel<string, Record<"Main", Definition>>
: Definition extends prismic.CustomTypeModelDefinition
? prismic.CustomTypeModel<string, Definition>
: never;
: never) & {
label: NonNullable<prismic.CustomTypeModel["label"]>;
};

export const customType = <
Definition extends
Expand All @@ -60,7 +62,7 @@ export const customType = <

const format = config.format ?? faker.randomElement(["page", "custom"]);

let json = {} as MockCustomTypeModel<Definition>["json"];
let json = {} as prismic.CustomTypeModelDefinition;

if ("fields" in config && config.fields) {
json = { Main: config.fields } as typeof json;
Expand Down
Loading