Serialize non-identifier object keys as valid JavaScript
Author: dajiaohuangCreated Sep 25, 2026Updated Sep 25, 2026
@json-render/codegen 0.21.0 can emit invalid JavaScript when an object value has a non-identifier key. Reproduced from main at c2600d73908ed505e6d726f5b6f969ba8f597ce7 on Node v24.14.1.
On the current main source, this call:
serializePropValue({ "data-testid": "widget" }).valuereturns:
{ data-testid: "widget" }That output throws SyntaxError: Unexpected token '-' when parsed as a JavaScript object literal. data-testid is a valid JSON property name, so consumers using this public serialization helper cannot generate valid code for ordinary object props with hyphenated keys.
Expected: emit valid JavaScript for arbitrary string property names while preserving their values. The package currently has traversal tests but no focused serializer regression test.
Source: vercel-labs/json-render