From f9ad34e2bf27c224d3b736f06f0e2a6eadb4d22e Mon Sep 17 00:00:00 2001 From: HubM Date: Wed, 1 Nov 2023 10:25:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20typeguard=20faqtarget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- typeguards/index.ts | 0 types/Faq.ts | 10 ++++++++-- types/index.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 typeguards/index.ts diff --git a/package.json b/package.json index 37bb8c1..719aee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bdxio/bdxio.types", - "version": "1.3.3", + "version": "1.3.4", "types": "dist/index.d.ts", "files": [ "/dist" diff --git a/typeguards/index.ts b/typeguards/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/types/Faq.ts b/types/Faq.ts index 4fab5b5..5e81f43 100644 --- a/types/Faq.ts +++ b/types/Faq.ts @@ -1,8 +1,14 @@ -export const FAQTargets = ["speakers", "sponsors", "participants"] as const; +export const faqTargets = ["speakers", "sponsors", "participants"] as const; + +type FAQTargets = (typeof faqTargets)[number] + +export function isFAQTarget(value: any): value is FAQTargets { + return faqTargets.includes(value); +} export type FAQTarget = { id: number; - target: (typeof FAQTargets)[number]; + target: (typeof faqTargets)[number]; description?: string; createdAt: string; publishedAt: string; diff --git a/types/index.ts b/types/index.ts index f72e0b2..e58e267 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,7 +1,7 @@ export type { Category } from "./Category"; export type { Edition } from "./Edition"; export type { FAQQuestion, FAQTarget } from "./Faq"; -export { FAQTargets } from "./Faq"; +export { faqTargets, isFAQTarget } from "./Faq"; export type { Format } from "./Format"; export type { Media } from "./Media"; export type { Offer } from "./Offer";