Skip to content

Conversation

@nkgentile
Copy link
Contributor

@nkgentile nkgentile commented Jan 7, 2026

Summary

TypeGen now preserves non-identifier property keys by quoting them instead of transforming them to camelCase.

Before: "my-field" in GROQ → myField in generated types (didn't match runtime)
After: "my-field" in GROQ → "my-field" in generated types (matches runtime)

Valid JavaScript identifiers remain unquoted:

{
  _id: string;           // valid identifier - unquoted
  "my-field": string;    // invalid identifier - quoted
}

Property keys that aren't valid JS identifiers (kebab-case, spaces, leading digits, etc.) are now quoted instead of transformed to camelCase. Generated types now match runtime data.

Users accessing kebab-cased keys via camelCase will get type errors:

// Before: types didn't match runtime
result.myField  // TS valid, undefined at runtime

// After: types match runtime  
result["my-field"]  // both TS and runtime agree

Test plan

  • Added comprehensive test covering valid identifiers (unquoted) and invalid identifiers (quoted)
  • Updated existing test snapshots
  • All 100 tests pass

@nkgentile nkgentile requested a review from a team as a code owner January 7, 2026 19:23
@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
page-building-studio Ready Ready Preview, Comment Jan 8, 2026 9:44am
test-studio Ready Ready Preview, Comment Jan 8, 2026 9:44am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
studio-workshop Ignored Ignored Preview Jan 8, 2026 9:44am
test-next-studio Ignored Ignored Jan 8, 2026 9:44am

@nkgentile nkgentile requested a review from kbrabrand January 7, 2026 19:24
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-j7nmga3xr.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-j7nmga3xr.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11736-chromium-20812374908 || pr-11736-firefox-20812374908 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11736-chromium-20812374908
  SANITY_E2E_DATASET_FIREFOX=pr-11736-firefox-20812374908

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@nkgentile nkgentile requested a review from sgulseth January 7, 2026 19:24
@nkgentile nkgentile marked this pull request as draft January 7, 2026 19:24
sgulseth
sgulseth previously approved these changes Jan 7, 2026
Copy link
Member

@sgulseth sgulseth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

⚡️ Editor Performance Report

Deploying studio and running performance tests…

@nkgentile nkgentile changed the title feat(typegen)!: preserve non-identifier keys in generated types Preserve non-identifier keys in generated types Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.51% 64324 / 144504
🔵 Statements 44.51% 64324 / 144504
🔵 Functions 48.02% 3375 / 7027
🔵 Branches 79.66% 13003 / 16323
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/@sanity/codegen/src/typescript/helpers.ts 96.92% 94.44% 100% 96.92% 76-77
packages/@sanity/codegen/src/typescript/schemaTypeGenerator.ts 96.89% 97.89% 100% 96.89% 104-110, 194-195
Generated in workflow #49519 for commit 730afd9 by the Vitest Coverage Report Action

kbrabrand
kbrabrand previously approved these changes Jan 7, 2026
Copy link
Contributor

@kbrabrand kbrabrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@nkgentile nkgentile force-pushed the feature/preserve-projection-key-casing-in-typegen branch from aa3404f to f48041b Compare January 7, 2026 19:47
@nkgentile nkgentile self-assigned this Jan 7, 2026
@nkgentile nkgentile marked this pull request as ready for review January 7, 2026 19:48
@nkgentile nkgentile changed the title Preserve non-identifier keys in generated types fix(typegen): preserve non-identifier keys in generated types Jan 7, 2026
@nkgentile nkgentile dismissed stale reviews from sgulseth and kbrabrand via f48041b January 7, 2026 23:01
@nkgentile nkgentile force-pushed the feature/preserve-projection-key-casing-in-typegen branch 2 times, most recently from f48041b to f1cc467 Compare January 7, 2026 23:03
kbrabrand
kbrabrand previously approved these changes Jan 8, 2026
@sgulseth sgulseth merged commit eaccb7a into main Jan 8, 2026
76 of 79 checks passed
@sgulseth sgulseth deleted the feature/preserve-projection-key-casing-in-typegen branch January 8, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants