Types for your answers
npx seaforms pull writes a .seaforms.d.ts beside each form’s file. For the contact form, src/forms/contact.seaforms.d.ts:
// Types for the answers to contact.seaforms.json, revision 3.// Made by the Seaforms CLI. Don't edit it: pull the form again after you publish a change.
/** * A submission's answers, keyed by question, as webhooks and the Seaforms API send them. An answer * is optional when the question can be left blank or only shows sometimes. A webhook set to send * only some questions leaves the others out. */export interface ContactAnswers { /** Name */ name: string; /** Email */ email: string; /** What’s it about? */ topic: "sales" | "support" | "press" | "something-else"; /** Message */ message: string;}
/** Which thank-you showed: `ending` in `onSubmitted`. */export type ContactEnding = "thanks";
/** The form's steps: `stepId` in `onStep`. */export type ContactStep = "get-in-touch";Don’t edit it: pull again after you publish a change, and it’s written again.
What’s in it
Section titled “What’s in it”<Name>Answers: a submission’s answers, keyed by each question’s key, as webhooks and the API send them. An answer is optional when the question can be left blank or only shows sometimes. Tick boxes, consent and quantities are always there when they always show.<Name>Ending: which thank-you showed:endinginonSubmittedand in a submission.<Name>Step: each step’s ID:stepIdinonStep.
The name comes from the form’s: contact gives ContactAnswers, project-enquiry gives ProjectEnquiryAnswers.
Using them
Section titled “Using them”import type { ContactAnswers } from "@/forms/contact.seaforms";
const answers = event.data.answers as ContactAnswers;if (answers.topic === "sales") { // …}A webhook set to send only some questions leaves the others out, so treat its answers as Partial<ContactAnswers>.
For a file you downloaded
Section titled “For a file you downloaded”If you saved a form’s file from the app instead of pulling it, write its types with types. It needs no sign-in and no network:
npx seaforms types src/formspnpm dlx seaforms types src/formsyarn dlx seaforms types src/formsbunx seaforms types src/formsThe types follow our logic engine itself: our tests check them against hundreds of real runs of every template, and compile them with TypeScript.
ChatGPT is a trademark of OpenAI, and Claude and Claude Code are trademarks of Anthropic. Other product names and logos belong to their owners. None of them makes or endorses Seaforms. Trademarks