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 will it happily ship a slot render that is quietly broken against the new shape?
I am trying to decide whether to trust these types as a real safety net or just treat them as editor hints. Which one is it in practice?
2 answers
Real safety net, as long as you type the fetch against the slot. The CLI generates a slots.d.ts describing each slot's content shape, and if you annotate the fetch with that slot type, a mismatch between what your component reads and what the schema now produces surfaces as a type error at build rather than at runtime.
We lean on this in CI. The generated types caught a schema change before it ever hit prod, best DX I have had for CMS personalization. Someone bumped a component, regenerated the types, and the build went red on the components that still read the old field. Nothing shipped broken.
One thing that makes this smoother: commit the slots.d.ts file. If it is in version control the build type-checks against it directly and does not need to hit the API at build time to know the shapes, which keeps CI hermetic and fast.
Pair that with pinning the slot version in your fetch so the committed type matches exactly what the code expects. If you leave the version off, the type and the runtime schema can drift apart and you lose the guarantee you are asking about.
That is what I wanted to hear. Types committed, versions pinned, fetch annotated. Treating them as the guardrail from now on.