title | description | tags | author | excerpt | publishedAt | ogImage | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
Introducing: The XState CLI |
Get ready to run XState’s typegen commands outside of VSCode in our all-new CLI. |
|
|
Get ready to run XState’s typegen commands outside of VSCode in our all-new CLI. |
2022-03-03 |
Around a month ago, we released TypeScript Typegen - an enormous upgrade to the TypeScript experience for XState.
We’ve had a great response to it so far, but it’s only been available for VSCode users.
Until now. With our new XState CLI, you can get Typegen from the command line.
- Read the full documentation on the
@xstate/cli
docs. - Check out our updated TypeScript Typegen guide.
- Find the code on the @xstate/cli GitHub repo.
npm install @xstate/cli
OR
yarn add @xstate/cli
xstate typegen "src/**/*.tsx?"
Run the typegen against a glob of files. This will scan every targeted file and generate a typegen file accompanying it. It will also import the typegen into your file, as described in our typegen documentation.
Ensure you wrap your glob in quotes so that it executes correctly. Otherwise, you’ll get unexpected results.
xstate typegen "src/**/*.tsx?" --watch
Runs the task on a watch, monitoring for changed files and running the typegen script against them.
We’re really excited about the CLI, and all the cool things it’ll enable. The typegen really is just the surface. If you’ve got ideas for what we could do with it, don’t hesitate to add a feature request to the xstate-tools
repo.