BridgeJS: Swift Array support#542
Merged
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom Jan 29, 2026
Merged
Conversation
kateinoigakukun
approved these changes
Jan 29, 2026
Member
There was a problem hiding this comment.
Awesome work, thanks!
Overall it looks good to me. A few things to follow up but we can incubate in the main branch.
- Missing support for some element types:
JSObject@JSClass struct
- Import-side support
- Specialized optimization for integer/float Arrays
- For example, we can use
Int32Arrayfor[Int]cloning
- For example, we can use
- Code size concern
- Seems like we are currently generating inline lifting/lowring code
- We might be able to extract and generalize as a runtime code (in BridgeJSIntrinsics.swift)
Member
Author
|
@kateinoigakukun thanks for feedback, all the great points. I have WIP for integer / floats optimization, I can add JSObject and @jsclass struct support as well. I’ll think on and explore code size optimization. As for import side, I’d skip on it on for now, I haven’t implemented import side type yet, but could take a stab at it given new macro based swift code, but it won’t be my priority over next weeks 🙏 |
Member
|
No worries, I'll take it over 😉 |
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.
BridgeJS: Swift Array Support
This PR adds the ability to pass Swift arrays to and from JavaScript using the BridgeJS plugin.
Example
Swift:
JavaScript:
Generated TypeScript:
Supported Array Types / Features
[Int],[Double],[Bool],[String][MyStruct][MyClass][[Int]][Int]?[Int?][MyProtocol]How It Works
Arrays use copy semantics when crossing the Swift/JavaScript boundary:
Testing
Documentation
Exporting-Swift-Array.mdcovering array usage, supported types, and copy semantics