A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
refactor(pdf): replace ts-pattern match chains with satisfies Record maps
Amruth Pillaicf738b9306fb
diff --git a/packages/pdf/package.json b/packages/pdf/package.jsonindex 7d8ab648d..d7884c640 100644--- a/packages/pdf/package.json+++ b/packages/pdf/package.json@@ -28,8 +28,7 @@"node-html-parser": "^8.0.4","phosphor-icons-react-pdf": "^0.1.3","react": "^19.2.7",- "react-pdf-html": "^2.1.5",- "ts-pattern": "^5.9.0"+ "react-pdf-html": "^2.1.5"},"devDependencies": {"@react-pdf/types": "^2.11.1",diff --git a/packages/pdf/src/templates/shared/sections.tsx b/packages/pdf/src/templates/shared/sections.tsxindex cddc92314..7d3811393 100644--- a/packages/pdf/src/templates/shared/sections.tsx+++ b/packages/pdf/src/templates/shared/sections.tsx@@ -3,6 +3,7 @@ import type {AwardItem,CertificationItem,CoverLetterItem,+ CustomSectionType,EducationItem,ExperienceItem,InterestItem,@@ -22,7 +23,6 @@ import type { ReactNode } from "react";import type { StyleInput, TemplatePlacement } from "./styles";import type { CustomItemSection, ItemSection } from "./types";import { Children, createContext, isValidElement, use } from "react";-import { match } from "ts-pattern";import { View } from "#react-pdf-renderer";import { useRender } from "../../context";import { getResumeSectionIcon } from "../../section-icon";@@ -929,51 +929,50 @@ const CustomSection = ({ sectionId, showHeading = true }: CustomSectionProps) =>if (!customSection) return null;- return match(customSection.type)- .with("summary", () => (+ // ponytail: satisfies Record<CustomSectionType,...> gives compile-time exhaustiveness without ts-pattern+ const customSectionMap = {+ summary: () => (<CustomSummarySection section={customSection as CustomItemSection<SummaryItem>} showHeading={showHeading} />- ))- .with("profiles", () => (+ ),+ profiles: () => (<ProfileSection sectionId={sectionId} sectionData={customSection as CustomItemSection<ProfileItem>} />- ))- .with("experience", () => (+ ),+ experience: () => (<ExperienceSection sectionId={sectionId} sectionData={customSection as CustomItemSection<ExperienceItem>} />- ))- .with("education", () => (+ ),+ education: () => (<EducationSection sectionId={sectionId} sectionData={customSection as CustomItemSection<EducationItem>} />- ))- .with("projects", () => (+ ),+ projects: () => (<ProjectsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<ProjectItem>} />- ))- .with("skills", () => (- <SkillsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<SkillItem>} />- ))- .with("languages", () => (+ ),+ skills: () => <SkillsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<SkillItem>} />,+ languages: () => (<LanguagesSection sectionId={sectionId} sectionData={customSection as CustomItemSection<LanguageItem>} />- ))- .with("interests", () => (+ ),+ interests: () => (<InterestsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<InterestItem>} />- ))- .with("awards", () => (- <AwardsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<AwardItem>} />- ))- .with("certifications", () => (+ ),+ awards: () => <AwardsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<AwardItem>} />,+ certifications: () => (<CertificationsSectionsectionId={sectionId}sectionData={customSection as CustomItemSection<CertificationItem>}/>- ))- .with("publications", () => (+ ),+ publications: () => (<PublicationsSection sectionId={sectionId} sectionData={customSection as CustomItemSection<PublicationItem>} />- ))- .with("volunteer", () => (+ ),+ volunteer: () => (<VolunteerSection sectionId={sectionId} sectionData={customSection as CustomItemSection<VolunteerItem>} />- ))- .with("references", () => (+ ),+ references: () => (<ReferencesSection sectionId={sectionId} sectionData={customSection as CustomItemSection<ReferenceItem>} />- ))- .with("cover-letter", () => <CoverLetterSection section={customSection as CustomItemSection<CoverLetterItem>} />)- .exhaustive();+ ),+ "cover-letter": () => <CoverLetterSection section={customSection as CustomItemSection<CoverLetterItem>} />,+ } satisfies Record<CustomSectionType, () => ReactNode>;++ return customSectionMap[customSection.type]();};export const Section = ({ section, placement, showHeading = true }: SectionProps) => {@@ -981,26 +980,29 @@ export const Section = ({ section, placement, showHeading = true }: SectionPropsif (!isSectionVisible(section, data)) return null;+ // ponytail: satisfies exhaustiveness over built-in types; custom IDs fall through to CustomSection+ const builtInSectionMap = {+ summary: () => <SummarySection showHeading={showHeading} />,+ profiles: () => <ProfileSection />,+ experience: () => <ExperienceSection />,+ education: () => <EducationSection />,+ projects: () => <ProjectsSection />,+ skills: () => <SkillsSection />,+ languages: () => <LanguagesSection />,+ interests: () => <InterestsSection />,+ awards: () => <AwardsSection />,+ certifications: () => <CertificationsSection />,+ publications: () => <PublicationsSection />,+ volunteer: () => <VolunteerSection />,+ references: () => <ReferencesSection />,+ } satisfies Record<Exclude<CustomSectionType, "cover-letter">, () => ReactNode>;++ const render = (builtInSectionMap as Record<string, (() => ReactNode) | undefined>)[section];+return (<TemplatePlacementProvider placement={placement}><SectionStyleProvider context={getSectionStyleRuleContext(data, section)}>- {match(section)- .with("summary", () => <SummarySection showHeading={showHeading} />)- .with("profiles", () => <ProfileSection />)- .with("experience", () => <ExperienceSection />)- .with("education", () => <EducationSection />)- .with("projects", () => <ProjectsSection />)- .with("skills", () => <SkillsSection />)- .with("languages", () => <LanguagesSection />)- .with("interests", () => <InterestsSection />)- .with("awards", () => <AwardsSection />)- .with("certifications", () => <CertificationsSection />)- .with("publications", () => <PublicationsSection />)- .with("volunteer", () => <VolunteerSection />)- .with("references", () => <ReferencesSection />)- .otherwise(() => (- <CustomSection sectionId={section} showHeading={showHeading} />- ))}+ {render ? render() : <CustomSection sectionId={section} showHeading={showHeading} />}</SectionStyleProvider></TemplatePlacementProvider>);diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3c4618524..2091c393d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -947,9 +947,6 @@ importers:react-pdf-html:specifier: ^2.1.5- ts-pattern:- specifier: ^5.9.0- version: 5.9.0devDependencies:'@react-pdf/types':specifier: ^2.11.1