Skip to content

Add discriminated union serialization tests - #2798

Closed
jar-stripe wants to merge 1 commit into
masterfrom
jar/discriminated-unions
Closed

Add discriminated union serialization tests#2798
jar-stripe wants to merge 1 commit into
masterfrom
jar/discriminated-unions

Conversation

@jar-stripe

Copy link
Copy Markdown
Contributor

Why?

Validates that the discriminated union type shapes work correctly in stripe-node before codegen produces these patterns. Covers both request-side (params with literal discriminator types) and response-side (object field access).

What?

  • Adds test/DiscriminatedUnion.spec.ts with 15 tests covering:
    • Standalone union: variant interfaces with literal discriminator property (request side)
    • Inline union: discriminator at parent level with nested variant (request side)
    • Response object field access and discriminator-based narrowing
    • JSON round-trip preservation

See Also

Changelog

No user-facing changes (test-only).

Tests discriminated union type shapes for both request-side (params with
literal discriminator) and response-side (object fields), covering
standalone and inline variants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@jar-stripe

Copy link
Copy Markdown
Contributor Author

Collapsed into #2801 (coercion PR now includes serialization tests)

@jar-stripe jar-stripe closed this Aug 6, 2026
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.

1 participant