Help articles
Configuring typegen in Sanity CLI config
As of version 4.19.0 it is recommended to configure typegen through the Sanity CLI config.
Since its introduction the sanity typegen command has been configured with a separate config file, typically at sanity-typegen.json.
The Sanity CLI tooling now include the configuration properties for type generation by specifying the same parameters under the typegen field of the CLI config.
import {defineCliConfig} from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: 'my-project-id',
dataset: 'dataset',
},
typegen: {
path: "./src/**/*.{ts,tsx,js,jsx}", // glob pattern to your typescript files. Can also be an array of paths
schema: "schema.json", // path to your schema file, generated with 'sanity schema extract' command
generates: "./sanity.types.ts", // path to the output file for generated type definitions
overloadClientMethods: true, // set to false to disable automatic overloading the sanity client
},
})Was this page helpful?