Skip to content

[http-server-js] handle Enum type in JSON serialization transpose helpers#10059

Merged
witemple-msft merged 3 commits intomicrosoft:mainfrom
witemple-msft:wt/typespec/9999-bug-error-unimplemented-transformjsonexprfortype
Mar 19, 2026
Merged

[http-server-js] handle Enum type in JSON serialization transpose helpers#10059
witemple-msft merged 3 commits intomicrosoft:mainfrom
witemple-msft:wt/typespec/9999-bug-error-unimplemented-transformjsonexprfortype

Conversation

@witemple-msft
Copy link
Member

Adds case "Enum": return expr; to both transposeExpressionToJson() and transposeExpressionFromJson() in json.ts. Generated TS enums map to primitive (string/numeric) values that are directly JSON-compatible, so a no-op return is semantically correct.

Fixes #9999 — crash when a model property has an Enum type and the enclosing model requires a JSON serializer (e.g. because a property name is a reserved keyword or has a wire-name rename).

… helpers

Adds `case "Enum": return expr;` to both `transposeExpressionToJson()`
and `transposeExpressionFromJson()` in json.ts. Generated TS enums map
to primitive (string/numeric) values that are directly JSON-compatible,
so a no-op return is semantically correct.

Fixes microsoft#9999 — crash when a model property has an Enum type and the
enclosing model requires a JSON serializer (e.g. because a property
name is a reserved keyword or has a wire-name rename).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@witemple-msft witemple-msft changed the title fix(http-server-js): handle Enum type in JSON serialization transpose helpers [http-server-js] handle Enum type in JSON serialization transpose helpers Mar 17, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-server-js@10059

commit: fb48517

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

All changed packages have been documented.

  • @typespec/http-server-js
Show changes

@typespec/http-server-js - fix ✏️

fix: handle Enum type in JSON serialization transpose helpers to prevent crash when a model with an enum property requires a JSON serializer

@azure-sdk
Copy link
Collaborator

azure-sdk commented Mar 17, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@witemple-msft witemple-msft added this pull request to the merge queue Mar 19, 2026
Merged via the queue into microsoft:main with commit 6ef50a6 Mar 19, 2026
30 checks passed
@witemple-msft witemple-msft deleted the wt/typespec/9999-bug-error-unimplemented-transformjsonexprfortype branch March 19, 2026 21:45
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.

[Bug]: Error: Unimplemented: transformJsonExprForType: Enum

4 participants