Array member type name conflicts with built-in type
This error means an array member has been given the same name as one of the type names Sanity reserves. It's reported as an error, so the Studio shows its schema errors screen until you fix it.
Sanity Studio reports it as Found array member declaration with the same type name as a built-in type ("…"). Array members can not be given the same name as a built-in type.
When defining an array type in your schema you have the option to quickly declare several "inline" object types and give each one of them their own name to be able to distinguish between them. For example, the following could be used to define an array that can hold different variations of contact info without having to declare address and phone as separate schema types.
This lets you define "locally scoped", inline types that you don't want to re-use across other schema types.
import {defineArrayMember, defineField, defineType} from 'sanity'
export const contactInfo = defineType({
name: 'contactInfo',
type: 'array',
of: [
defineArrayMember({
type: 'object',
name: 'address',
fields: [defineField({name: 'street', type: 'string'})],
}),
defineArrayMember({
type: 'object',
name: 'phone',
fields: [defineField({name: 'number', type: 'string'})],
}),
],
})Inline object type names must not collide with the type names Sanity already ships with.
In a plain array, the error fires when a member's name is one of the reserved names and differs from that member's own type. Naming an inline object type string, reference, or image errors. Repeating the type as the name — {type: 'image', name: 'image'} — is redundant but allowed. Consider this example:
import {defineArrayMember, defineField, defineType} from 'sanity'
export const contactInfo = defineType({
name: 'contactInfo',
type: 'array',
of: [
defineArrayMember({
type: 'object',
name: 'address',
fields: [defineField({name: 'street', type: 'string'})],
}),
defineArrayMember({
type: 'object',
// Errors: "reference" is a built-in type name
name: 'reference',
fields: [defineField({name: 'caption', type: 'string'})],
}),
],
})Here, reference is a reserved name, so the second member errors. Pick another name, for example contactReference.
The reserved names are Sanity's built-in schema types: array, block, boolean, crossDatasetReference, date, datetime, document, email, file, geopoint, globalDocumentReference, image, number, object, reference, slug, span, string, telephone, text, and url.
The list is defined in coreTypes.ts in the Sanity monorepo.
The Studio also reuses this help link for an unrelated Portable Text problem. When a block array has a member that isn't a supported object-like type, the message is Block member types must be a supported object-like type. That one is not about naming, and renaming won't fix it — change the member's type. The supported built-in members are file, image, object, reference, crossDatasetReference, and globalDocumentReference, or a shorthand for one of your own object types, like {type: 'myObjectType'}.
If the name collides with one of your own schema types rather than a reserved one, the Studio raises a warning instead. See Array member type name is the same as a global type.