ricokahler / sanity-codegen

Generate TypeScript types from your Sanity.io schemas
sanity-codegen-dev.vercel.app
MIT License
270 stars 19 forks source link

[Still] TypeError: types.filter is not a function #325

Closed Adiyasa26 closed 11 months ago

Adiyasa26 commented 11 months ago
TypeError: types.filter is not a function
    at generateTypes (/home/adiyasa26/leren-turborepo/node_modules/.pnpm/sanity-codegen@0.9.8_@babel+core@7.22.8_@babel+preset-env@7.22.9_@babel+preset-react@7.22.5_@_zqzyi2w6z3oqrlqkrm62g4in2u/node_modules/sanity-codegen/generate-types.js:30:31)
    at cli (/home/adiyasa26/leren-turborepo/node_modules/.pnpm/sanity-codegen@0.9.8_@babel+core@7.22.8_@babel+preset-env@7.22.9_@babel+preset-react@7.22.5_@_zqzyi2w6z3oqrlqkrm62g4in2u/node_modules/sanity-codegen/cli.js:102:51)

Can anyone help me with this problem?

FYI, this is how i import defineArrayMember, defineField, etc

// ./schemas/.../author.ts
import { defineArrayMember, defineField, defineType } from 'sanity';

FYI, this is my schema.ts this file is located at the root

// ./schema.ts
...
import author from './schemas/document/author';
///

const schema: { types: SchemaTypeDefinition[] } = {
  types: [
    ...
    author,
    ...
  ],
};

export default schema;

I have followed the documentation provided, I have also tried debugging by changing the export schema to default export. And I am using Nextjs13.4

michelebruno commented 11 months ago

If you add

export default schema.types

to end of your schema files, it should work. Still I think it needs fixing

Adiyasa26 commented 11 months ago

If you add

export default schema.types

to end of your schema files, it should work. Still I think it needs fixing

Aw, my bad, thank you so much, now my program works.