The @xstate/cli package (opens new window) contains commands for running typegen. It's pretty small right now, but we're planning on adding many cool features.
npm install @xstate/cli
# xstate typegen
xstate typegen "src/**/*.ts?(x)"
Run the typegen against a glob. This will scan every file targeted, and generate a typegen file accompanying it. It will also import the typegen into your file, as described in our typegen documentation (opens new window).
Ensure you wrap your glob in quotes so that it executes correctly.
xstate typegen "src/**/*.ts?(x)" --watch
Runs the task on a watch, monitoring for changed files and running the typegen script against them.