Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
schemaTypes in sanity io

I am facing problem in schemaTypes of Sanity io All the details are mentioned below Any problem regarding the question U can ask me

userSchema.js

    name:'abouts',
    title:'Abouts',
    type: 'document',
    fields:[
        {
            name:'title',
            title:'Title',
            type:'string'
        },
        {
            name:'description',
            title:'Description',
            type:'string'
        },
        {
            name:'imgUrl',
            title:'ImgUrl',
            type: 'image',
            options: {
              hotspot: true,
            },
        },

    ]
} 

schema.js

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'
import { userSchema } from './userSchema'

export default createSchema({
  
  name: 'default',
  types: schemaTypes.concat([userSchema]),
}) 

Now, schemaTypes is an OBJECT as we can check from "typeof" operator, I dont understand how can we use .concat() with an Object, like .concat() is an array function which can be applied with Array, So how schemaTypes.concat([userSchema]) is working correctly??

Please help me regarding this. Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In JavaScript you will never get 'array' back from typeof. typeof will return 'object' for any non-primitive other than functions (and the primitive null).

What I expect you are looking for is the Array.isArray() method. Logging Array.isArray(schemaTypes) should return true, meaning that schemaTypes is in fact an array and can use the .concat() method.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!