UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

18 lines (17 loc) 827 B
import type { DateField } from "../types/value/date"; import type { TimestampField } from "../types/value/timestamp"; /** * The return type of `asDate()`. */ type AsDateReturnType<Field extends DateField | TimestampField | null | undefined> = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null; /** * Transforms a date or timestamp field into a JavaScript Date object * * @param dateOrTimestampField - A date or timestamp field from Prismic * * @returns A Date object, null if provided date is falsy * * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp} */ export declare const asDate: <Field extends DateField | TimestampField | null | undefined>(dateOrTimestampField: Field) => AsDateReturnType<Field>; export {};