diff --git a/studio/schemas/documents/compensations.ts b/studio/schemas/documents/compensations.ts index 82e9bc20e..7aa300b1b 100644 --- a/studio/schemas/documents/compensations.ts +++ b/studio/schemas/documents/compensations.ts @@ -49,11 +49,13 @@ const compensations = defineType({ title: title.name, }, prepare({ title }) { - const translatedTitle = isInternationalizedString(title) - ? firstTranslation(title) - : null; + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } return { - title: translatedTitle ?? undefined, + title: firstTranslation(title) ?? undefined, }; }, }, diff --git a/studio/schemas/fields/callToActionFields.ts b/studio/schemas/fields/callToActionFields.ts index 1eaacc6bd..9edf177c7 100644 --- a/studio/schemas/fields/callToActionFields.ts +++ b/studio/schemas/fields/callToActionFields.ts @@ -18,11 +18,13 @@ const callToActionField = defineField({ title: "linkTitle", }, prepare({ title }) { - const translatedTitle = isInternationalizedString(title) - ? firstTranslation(title) - : null; + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } return { - title: translatedTitle ?? undefined, + title: firstTranslation(title) ?? undefined, subtitle: "Call to Action", }; }, diff --git a/studio/schemas/objects/compensations/benefitsByLocation.ts b/studio/schemas/objects/compensations/benefitsByLocation.ts index 33238637f..3eefe6778 100644 --- a/studio/schemas/objects/compensations/benefitsByLocation.ts +++ b/studio/schemas/objects/compensations/benefitsByLocation.ts @@ -80,14 +80,16 @@ export const benefitsByLocation = defineField({ type: benefitType.name, }, prepare({ title, type }) { - const translatedTitle = isInternationalizedString(title) - ? firstTranslation(title) - : null; + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } const subtitle = BENEFIT_TYPES.find((o) => o.value === type)?.title ?? "Unknown benefit type"; return { - title: translatedTitle ?? undefined, + title: firstTranslation(title) ?? undefined, subtitle, }; }, diff --git a/studio/schemas/objects/link.ts b/studio/schemas/objects/link.ts index 0d6107d70..abc752612 100644 --- a/studio/schemas/objects/link.ts +++ b/studio/schemas/objects/link.ts @@ -193,11 +193,13 @@ export const link = defineField({ type: "linkType", }, prepare({ title, type }) { - const translatedTitle = isInternationalizedString(title) - ? firstTranslation(title) - : null; + if (!isInternationalizedString(title)) { + throw new TypeError( + `Expected 'title' to be InternationalizedString, was ${typeof title}`, + ); + } return { - title: translatedTitle ?? undefined, + title: firstTranslation(title) ?? undefined, subtitle: type ? type.charAt(0).toUpperCase() + type.slice(1) : "", }; },