CLI reference

TypeGen

Customize TypeGen in your CLI configuration

v4.19.0

This release introduces a change to the way you define Sanity TypeGen configurations, as well as bug fixes for asset selection with required field validation, schema validation in the CLI, and performance improvements for comments in the Portable Text Editor.

✨ Highlights

TypeGen configurations move to sanity.cli.ts

TypeGen configurations are now managed through the sanity.cli.ts configuration file. You can move your configurations over from sanity-typegen.json to the typegen key in the CLI config as shown below:

Before (now deprecated)

After

🐛 Notable bugfixes

  • Fixed an issue where sanity schema validate would fail because it couldn't find the sanity.video type. This command now correctly loads the configuration and includes default plugins.
  • Fixed an error where the assetRequired() validation rule prevented you from selecting assets in Media Library, creating a catch-22 where you couldn't pick an asset because the field required one.
  • Fixed an issue in Content Releases where the time input wasn't updating correctly when using a timezone different from your local one.
  • Fixed a bug causing excessive mutations in the comments dataset when working in Portable Text Editor. In extreme cases, these mutations could result in rate limiting. The editor now only submits mutations for comments that have changed.
  • Improved document status copy for published documents, making it clear that timestamps reflect the last edit or publish time.

Introduction of Sanity TypeGen and Tasks Beta

v3.36.0

Installation and upgrading

To initiate a new Studio without installing the CLI globally:

To upgrade a Sanity Studio, run this command in its folder:

Sanity TypeGen (beta): Generate types for your schema and GROQ queries

This release comes with Sanity TypeGen, the new tooling in the Sanity CLI that enables extracting the schema into a static representation (schema.json) and to generate TypeScript type definition for it, as well as for GROQ query results.

You can learn more about Sanity TypeGen:

If you try out Sanity TypeGen, do let us know how it went in the #typescript channel in the Sanity community or to your customer success team.

Tasks (beta): Delegate work within Sanity Studio

This update also includes the beta of Tasks for Sanity Studio. It's a way to assign tasks related to documents, delegate them to team members, and track their status across the project.

A screenshot of the studio with the Task drawer open on the right side
Find the new Tasks in the upper right corner of the Studio

If you wish to disable tasks, you can do so by adding the following to sanity.config.ts:

export default defineConfig({
  …restOfConfig,
  unstable_tasks: {
    enabled: false,
  },
})

Documentation for Tasks is in the works and will be announced when ready.

🐛 Notable bugfixes

  • Fixes a bug where all fields got marked as non-optional when extracting schema with --enforce-required-fields.
  • Fixes a bug where Vision would insert a new line on cmd-return.

Problems with styled-components@5?

If you encounter an error such as TypeError: Cannot read properties of undefined (reading 'div'), please make sure your Studio doesn't depend on styled-components@5. Updating any such dependencies to styled-components@6 should resolve the error: