Skip to content

Commit

Permalink
docs: add MaybeLink description
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Dec 17, 2024
1 parent 4073174 commit 8217ae6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/types/migration/Link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import type { LinkType, OptionalLinkProperties } from "../value/link"

/**
* Adds `OptionalLinkProperties` to any type that looks like a link object (one
* that includes a valid `link_type` property).
*
* @example
*
* ```ts
* type Example = MaybeLink<PrismicDocument | LinkField>
* // PrismicDocument | (LinkField & OptionalLinkProperties)
* ```
*
* @typeParam T - The type to augment.
*/
export type MaybeLink<T> =
| Exclude<T, { link_type: (typeof LinkType)[keyof typeof LinkType] }>
| (Extract<T, { link_type: (typeof LinkType)[keyof typeof LinkType] }> &
Expand Down

0 comments on commit 8217ae6

Please sign in to comment.