Skip to content

feat: Support variants of union-style enums#1426

Merged
mrousavy merged 7 commits into
mainfrom
feat/support-variants-with-union-enums
Jun 30, 2026
Merged

feat: Support variants of union-style enums#1426
mrousavy merged 7 commits into
mainfrom
feat/support-variants-with-union-enums

Conversation

@mrousavy

Copy link
Copy Markdown
Owner

Adds support for creating Variants of union-style enums as well.

Example:

type CameraPosition = "front" | "back" | "external"
interface CameraDevice extends HybridObject<...> { ... }

interface Config {
  input: CameraDevice | CameraPosition
}

Previously, this would've flattened input to CameraDevice | 'front' | 'back' | 'external' and therefore threw:

- ❌  Failed to generate spec for CameraSession! Error: String literal "external" cannot be represented in C++ because it is ambiguous between a string and a discriminating union enum.

Now this properly preserves the CameraPosition union type, and generates the variant properly.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
nitro-docs Skipped Skipped Jun 29, 2026 10:10pm

Request Review

@mrousavy mrousavy force-pushed the feat/support-variants-with-union-enums branch from 7af0ecc to 63b9d8c Compare June 29, 2026 21:04
type: TSMorphType,
isOptional: boolean
isOptional: boolean,
typeNode?: TypeNode

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like the fact that we have to pass in a new optional parameter (TypeNode) here now. This seems super hacky.
But not sure if we can do anything to prevent this tbh.

@mrousavy mrousavy marked this pull request as ready for review June 30, 2026 08:43
@mrousavy mrousavy merged commit 8e31e1a into main Jun 30, 2026
19 checks passed
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