◐ Shell
clean mode source ↗

BridgeJS: Support optional @JS struct in imported function signatures by krodak · Pull Request #755 · swiftwasm/JavaScriptKit

Optional @js structs could not be used as parameters or return values of
imported (@JSFunction) signatures: the generator lowered Optional<Struct>
using the non-optional object-id ABI ([isSome, objectId] / a single Int32
return), for which no Optional lowering exists, so the generated thunk did
not compile.

Bridge optional @js structs through the stack ABI instead - an isSome
discriminator plus the struct fields - exactly like optional arrays and
dictionaries. Structs already conform to the stack-based bridging protocols,
so the existing _BridgedAsOptional/stack runtime extensions and the JS link's
stack handling already support this; only the import-side lowering/lifting in
the code generator needed to change.

Adds a jsRoundTripOptionalPoint runtime round-trip (some + none) and a
SwiftStructImports codegen snapshot.

MaxDesiatov

approved these changes Jun 8, 2026