Skip to content

fix(codegen): serialize object keys safely - #362

Open
dajiaohuang wants to merge 1 commit into
vercel-labs:mainfrom
dajiaohuang:fix/codegen-object-key-serialization
Open

dajiaohuang wants to merge 1 commit into
vercel-labs:mainfrom
dajiaohuang:fix/codegen-object-key-serialization

Conversation

@dajiaohuang

Copy link
Copy Markdown

Fixes #361.

Quote non-identifier object keys when serializing JavaScript object literals while keeping simple identifier keys readable. Emit __proto__ as a computed key so it remains an own data property rather than invoking object-literal prototype syntax.

Adds regression coverage for hyphenated keys, simple keys, and __proto__ preservation.

Validation:

  • pnpm exec vitest run packages/codegen/src/serialize.test.ts (3 tests pass)
  • pnpm --filter @json-render/codegen run typecheck (pass)
  • pnpm --filter @json-render/codegen run build (pass)
  • pnpm exec prettier --check packages/codegen/src/serialize.ts packages/codegen/src/serialize.test.ts (pass)
  • Node parser/semantics check for hyphenated and __proto__ keys (pass)

The full workspace pnpm type-check was attempted but could not complete on this Windows host: Turbo reaches the unrelated @json-render/next#build script, which uses rm -rf dist and fails because rm is unavailable.

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@dajiaohuang is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Serialize non-identifier object keys as valid JavaScript

1 participant