From a6abf19300f366286a1babb59b53f2eebcdb29bc Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 26 Apr 2024 12:50:23 -1000 Subject: [PATCH] fix: treat a custom type model's `label` property as non-nullable --- src/model/customType.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/model/customType.ts b/src/model/customType.ts index 2972962..86c1926 100644 --- a/src/model/customType.ts +++ b/src/model/customType.ts @@ -33,11 +33,13 @@ type MockCustomTypeModel< Definition extends | prismic.CustomTypeModelTab | prismic.CustomTypeModelDefinition, -> = Definition extends prismic.CustomTypeModelTab +> = (Definition extends prismic.CustomTypeModelTab ? prismic.CustomTypeModel> : Definition extends prismic.CustomTypeModelDefinition ? prismic.CustomTypeModel - : never; + : never) & { + label: NonNullable; +}; export const customType = < Definition extends @@ -60,7 +62,7 @@ export const customType = < const format = config.format ?? faker.randomElement(["page", "custom"]); - let json = {} as MockCustomTypeModel["json"]; + let json = {} as prismic.CustomTypeModelDefinition; if ("fields" in config && config.fields) { json = { Main: config.fields } as typeof json;