Repository navigation
fix(codegen): preserve string values in generated JSX - #383
Draft
KennyMcSimpson wants to merge 1 commit into
Draft
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
Conversation
Contributor
|
@KennyMcSimpson 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #379.
String props are escaped as JavaScript strings, but
serializeProps()currently places them in quoted JSX attributes. A value such asQuoted "temperature"then produces invalid TSX. Backslashes and newlines can also compile to a different value.Emit string props as JSX expressions, so the existing JavaScript escaping is interpreted correctly:
title={"Quoted \"temperature\""}.The tests compile the generated TSX and evaluate its props for both quote modes. They cover quotes, apostrophes, line breaks, tabs, backslashes, entities, and empty strings. Boolean shorthand and nullish prop handling are covered as well. The package docs, web reference, skill examples, and codegen page's documentation parity hashes are updated to match the output.
Testing
pnpm exec vitest run packages/codegen/src/serialize.test.ts packages/codegen/src/traverse.test.ts— 13 tests passed.pnpm type-check— passed across all 60 tasks.pnpm --filter @json-render/codegen typecheck— passed.