Skip to content
sproutboat
Esc
navigateopen⌘Jpreview
On this page

Generated types

sproutboat types writes sproutboat-env.d.ts so env and the handler are fully typed.

env is a global, so an editor has nothing to infer from: env.SESSIONS is an undeclared identifier until you generate types.

bunx sproutboat types      # writes sproutboat-env.d.ts
npx sproutboat types       # writes sproutboat-env.d.ts

The file declares one property per binding, typed by kind, and references the binding shapes shipped with the CLI. Commit it, and add it to your tsconfig’s include.

Handler typing

Generated types also type the handler itself, which catches the Workers habit of passing env as a parameter:

export default {
  // error: env is a global, not a parameter. Second param is ctx, not env.
  fetch(request, env, ctx) { /* ... */ },
} satisfies SproutboatHandler;

Was this page helpful?