Answers about typescript
Questions and answers from the Croct community about typescript.
A content publish broke my build because the slot type changed, how do I stop that?
A colleague published a schema change on one of our slots this morning, and my very next build started failing because the content shape had changed under me.…
Best way to get typed slot content in a TypeScript Hydrogen project?
Our Hydrogen storefront is strict TypeScript, no implicit any, and I would like slot content to be typed end to end rather than casting the fetch result to…
How do I get TypeScript types for the content a slot returns in React?
I am tired of treating slot content as any in my React components. Right now I destructure useContent('home-hero') and TypeScript has no idea what the fields…
How do I get the content from a slot properly typed in TypeScript?
wiring up content fetching and the content coming back is basically unknown, so I get no autocomplete and no safety on the fields. Right now I am casting it…
Do the generated slot types actually catch schema changes at build time?
I committed the CLI-generated slots type file and I want to confirm the behaviour I am hoping for: if a component schema changes, does my Vue build fail, or…
typescript-eslint no-floating-promises flags every croct.track and croct.identify call
Enabled the strict typescript-eslint preset. Result: on every croct.track() and croct.identify() in the codebase. Before I blanket-void them: is awaiting…
Should I commit the generated slots.d.ts or let it regenerate on each build?
Project uses typed slot content. The CLI generates a slots.d.ts file. Deciding between two options. gitignore it and regenerate in CI, or commit it. Not sure…
How should croct.json5 version specifiers and slots.d.ts play with CI builds?
Setting up CI for a Next.js project and I want the Croct typing story fully deterministic. Three questions: How exactly do version specifiers in croct.json5…
Added a new slot in the dashboard, TypeScript says the slot ID does not exist
Created a promo-banner slot in the dashboard ten minutes ago, referenced it in code, and tsc is having none of it: We run strict everything so I can't just…
How do Strapi component fields relate to Croct component schemas?
Strict TypeScript project, and I care a lot about having one source of truth for types. Our Strapi components are typed end to end today. If I map a Strapi…
One croct.json5 for the whole pnpm workspace or one per Next.js app?
We run two Next.js applications in a single pnpm workspace. Both belong to the same Croct workspace, but they use entirely different slots. I am setting up…
Combining sanity typegen with the generated slots.d.ts, one type system or two?
We use sanity typegen to type all our GROQ results, and now the Croct CLI has generated a slots.d.ts in the repo. So I have two generated type sources…