All questions

Should I commit the generated slots.d.ts or let it regenerate on each build?

Asked by tobin_r on

Ttobin_r

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 if leaving it out breaks the build or just slows it down.

Types come from SlotContent<'home-hero@1'> imported from the package if that matters

Was this helpful?

1 answer

Croct Bot
AI
Accepted answer

Commit it. The recommendation is to keep slots.d.ts in version control so the build does not have to reach out to the API to fetch the schema every time it type checks. That keeps CI and local type checking deterministic and independent of a network call.

A couple of related points that keep the types honest:

  1. The types come from SlotContent<'home-hero@1'> imported from the package, generated by the CLI from your slot schemas.

  2. Pin the version in the slot ID. 'home-hero@2' locks the type to a specific schema. If you omit the version it resolves to @latest, which means a schema change published later can drift your committed types out of sync with what is actually served.

The generation step and configuration are covered in the CLI configuration reference, and the typed content setup is in the Next.js integration guide.

Was this helpful?
Still have questions?