Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Latest commit

 

History

History
60 lines (42 loc) · 2.09 KB

2022-03-03-introducing-the-xstate-cli.mdx

File metadata and controls

60 lines (42 loc) · 2.09 KB
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.
cli
xstate
announcement
typescript
Matt Pocock
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.

Installation

npm install @xstate/cli

OR

yarn add @xstate/cli

Commands

xstate typegen <files>

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.

Options

xstate typegen "src/**/*.tsx?" --watch

Runs the task on a watch, monitoring for changed files and running the typegen script against them.

The Future

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.