Skip to content

Commit

Permalink
🎨 typeguard faqtarget
Browse files Browse the repository at this point in the history
  • Loading branch information
HubM committed Nov 1, 2023
1 parent 749a7c0 commit 6df0e08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Empty file added typeguards/index.ts
Empty file.
10 changes: 8 additions & 2 deletions types/Faq.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion types/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit 6df0e08

Please sign in to comment.