diff --git a/src/lib/getOptionalLinkProperties.ts b/src/lib/getOptionalLinkProperties.ts index 7b1c5e18..d02a4396 100644 --- a/src/lib/getOptionalLinkProperties.ts +++ b/src/lib/getOptionalLinkProperties.ts @@ -15,13 +15,13 @@ export const getOptionalLinkProperties = ( ): OptionalLinkProperties => { const res: OptionalLinkProperties = {} - if ("variant" in input) { - res.variant = input.variant - } - if ("text" in input) { res.text = input.text } + if ("variant" in input) { + res.variant = input.variant + } + return res } diff --git a/src/lib/isMigrationValue.ts b/src/lib/isMigrationValue.ts index 72613978..122f602d 100644 --- a/src/lib/isMigrationValue.ts +++ b/src/lib/isMigrationValue.ts @@ -85,6 +85,10 @@ export const image = (value: UnknownValue): value is MigrationImage => { /** * Checks if a value is a migration link to media field. * + * - @remarks `OptionalLinkProperties` is included because + * `MigrationContentRelationship` may be a link field, not strictly a content + * relationship field. + * * @param value - Value to check. * * @returns `true` if `value` is a migration link to media field, `false` @@ -95,7 +99,7 @@ export const image = (value: UnknownValue): value is MigrationImage => { */ export const linkToMedia = ( value: UnknownValue, -): value is MigrationLinkToMedia => { +): value is MigrationLinkToMedia & OptionalLinkProperties => { return ( typeof value === "object" && value !== null && diff --git a/src/types/migration/Asset.ts b/src/types/migration/Asset.ts index de0233cb..401a07f8 100644 --- a/src/types/migration/Asset.ts +++ b/src/types/migration/Asset.ts @@ -72,7 +72,7 @@ export type MigrationImage = */ export type MigrationLinkToMedia = Pick< LinkToMediaField<"filled">, - "link_type" + "link_type" | "text" > & { /** * A reference to the migration asset used to resolve the link to media diff --git a/src/types/value/link.ts b/src/types/value/link.ts index cb9697c3..41a30fb8 100644 --- a/src/types/value/link.ts +++ b/src/types/value/link.ts @@ -88,6 +88,6 @@ export type FilledLinkToWebField = { // Remember to update the `getOptionalLinkProperties()` function when updating // this type. The function should check for every property. export type OptionalLinkProperties = { - variant?: string text?: string + variant?: string }