You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using defineConfig export from @sanity-typed/types, typescript raises an error when passing the config to the config property to the NextStudio component. The types are incompatible, specifically the validator property in defineField:
Types of parameters 'rule' and 'rule' are incompatible. Type 'RuleDef<DocumentRule, SanityDocument>' is missing the following properties from type '{ custom: (fn: CustomValidator ...
'use client'
/**
* This configuration is used to for the Sanity Studio that’s mounted on the `/app/studio/[[...tool]]/page.tsx` route
*/
import {visionTool} from '@sanity/vision'
import {structureTool} from 'sanity/structure'
import {defineConfig as untypedDefineConfig} from 'sanity'
// Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works
import {apiVersion, dataset, projectId} from './src/sanity/env'
import schemaTypes from '@/sanity/schemaTypes'
import {structure} from '@/sanity/structure'
import {defineConfig} from '@sanity-typed/types'
import {InferSchemaValues} from '@sanity-typed/types'
const CONFIG_PARAMS = {
basePath: '/studio',
projectId,
dataset,
// Add and edit the content schema in the './sanity/schemaTypes' folder
schema: {types: schemaTypes},
plugins: [
structureTool({structure}),
// Vision is for querying with GROQ from inside the Studio
// https://www.sanity.io/docs/the-vision-plugin
visionTool({defaultApiVersion: apiVersion}),
],
}
const UNTYPED_CONFIG_PARAMS = {...CONFIG_PARAMS, schema: {types: schemaTypes} as { types: any }}
export const untypedSanityConfig = untypedDefineConfig(UNTYPED_CONFIG_PARAMS);
const sanityConfig = defineConfig(CONFIG_PARAMS);
export default sanityConfig;
export type SanityValues = InferSchemaValues<typeof sanityConfig>
Basically in my sanity.config.ts I keep two versions of the config; one generated with this tool and one vanilla (untyped). I pass the untyped to the NextStudio instance and keep my typed versions around elsewhere. The critical line is where I cast {types: SchemaTypes} as { types: any }.
When using
defineConfig
export from@sanity-typed/types
, typescript raises an error when passing the config to theconfig
property to theNextStudio
component. The types are incompatible, specifically thevalidator
property indefineField
:Which versions of Sanity are you using?
@sanity/cli (global) 3.49.0 (latest: 3.50.0)
@sanity/demo 1.0.2 (latest: 2.0.0)
@sanity/vision 3.28.0 (latest: 3.50.0)
sanity 3.49.0 (latest: 3.50.0)
What operating system are you using?
macOS Sonoma 14.5
Which versions of Node.js / npm are you running?
10.5.0
v21.7.1
The text was updated successfully, but these errors were encountered: