@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
20 lines (19 loc) • 604 B
TypeScript
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];
}> & OptionalLinkProperties);