fix(typescript): dedupe discriminant in generated SSE protocol-union wire tests#15563
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Docs Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on
Docs generation runs |
Summary
Generated wire tests for SSE endpoints with protocol-discriminated unions previously emitted both an explicit discriminant key and a spread of the deserialized data, which itself already contained the discriminant. Under TypeScript
strict, this produced aTS2783: '<field>' is specified more than once, so this usage will be overwrittenbuild error (e.g. auth0/node-auth0#1331).This PR also fixes a related dead-code bug: the override that promotes a discriminant value from the data payload onto the SSE
event:line was running after the discriminant had been deleted from the copy, so it never fired.Example
For an SSE endpoint with a protocol-discriminated union and an example whose
event:line is empty:Before:
After:
The discriminant is now lifted onto the SSE
event:line and stripped fromdata, matching what the runtime SDK'sinjectDiscriminatorproduces.Test plan
streamEventsDiscriminantInDatainserver-sent-event-examplesthat exercises the empty-event:-line + discriminant-in-data shape.streamEventsContextProtocolsnapshot loses its redundantevent: "completion", ...{event: "completion", ...}wrapper — diff is clean.tsc --strict --noEmiton the regeneratedcompletions.test.tspasses (no TS2783).pnpm seed test --generator ts-sdk --fixture server-sent-event-examplespasses.🤖 Generated with Claude Code