I want to get typesafe value from form to properly map questions. Currently I've done this:
export const getSection = <T extends SelfFormValues["sections"][number]>( section: T | undefined, type: T["sectionType"]) => { if (!section) throw new Error("Section not found"); if (section.sectionType !== type) throw new Error("Section type mismatch"); return section;};
export const getSection = <T extends SelfFormValues["sections"][number]>( section: T | undefined, type: T["sectionType"]) => { if (!section) throw new Error("Section not found"); if (section.sectionType !== type) throw new Error("Section type mismatch"); return section;};
But i still get an error
Property 'questions' does not exist on type '{ answer: string; sectionType: "single"; sectionName: string; }
Property 'questions' does not exist on type '{ answer: string; sectionType: "single"; sectionName: string; }