Skip to content

State of typegen on large projects with latest Sanity version? #33

@lwmouneyrac

Description

@lwmouneyrac

Hi,

We upgraded to the latest Sanity package due to a Snyk security report.

Now typegen is reporting 300+ type errors (typegen has been made stricter)

It is due to the fact that typegen does not support:
Template literal fragments - reusable code like ${heroBlockFields}
Conditional projections - logic like _type == "heroBlock" => {...}

Our Current Workaround (Unsustainable):

  • Revert to old Sanity version
  • Run typegen
  • Upgrade back to latest version

The best way to solve it "properly" that we found:
Use @sanity-typegen-ignore on all queries and manually maintain query types separately from schema types.
Cost: Manual type maintenance for 26 queries, ongoing sync burden.

Questions:

  • Is this the recommended approach for projects using modular queries?
  • Are there plans to support template literal fragments in TypeGen?
  • TypeGen is marked "experimental" but also "recommended" - should production projects rely on it?

Kind regards

Jerome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions