BridgeJS: Support case enums as imported function parameters and returns#756
Merged
Merged
Conversation
Case enums (enums without raw values or associated values) already bridged across the export boundary as their Int32 tag, but the TypeScript import path rejected them with "Enum types are not yet supported in TypeScript imports". The JS glue already round-trips the tag in both directions, so enable case enums as imported (@JSFunction) parameters and return values by lowering and lifting that Int32 tag in the import context, matching the export side. Adds a CaseEnumImports round-trip test and an EnumCaseImport codegen snapshot.
44d4c22 to
7d3faa0
Compare
kateinoigakukun
approved these changes
Jun 8, 2026
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.
Overview
Case enums (Swift enums without raw values or associated values) could not be used as parameters or return values of imported (
@JSFunction) signatures. They already bridge across the export boundary as theirInt32tag, but the import path rejected them:The JavaScript glue already round-trips the
Int32tag in both directions; only the import-side type lowering and lifting in the code generator threw instead of producing the tag transfer.This change enables case enums as imported parameters and return values by lowering and lifting their
Int32tag in the import context, identical to how the export side already handles them. The bridged representation is the case index, with the JS side exposing the value table and a numeric tag type in the generated.d.ts.Adds an end-to-end runtime round-trip test and a codegen snapshot covering the new import shape.