BridgeJS: Add JSTypedArray as a recognized BridgeJS type#746
Merged
Conversation
MaxDesiatov
reviewed
May 13, 2026
Member
MaxDesiatov
left a comment
There was a problem hiding this comment.
Is there anything in documentation files that could be updated here?
MaxDesiatov
approved these changes
May 13, 2026
Member
MaxDesiatov
left a comment
There was a problem hiding this comment.
Seems quite straightforward, thanks! LGTM modulo possible documentation improvements.
9aaa777 to
90abc67
Compare
Add JSInt8Array, JSUint8Array, JSInt16Array, JSUint16Array, JSInt32Array, JSUint32Array, JSFloat32Array, JSFloat64Array typealiases and pre-seed them in SwiftToSkeleton so BridgeJS recognizes them in @js signatures. Users can now write: @js func processData(_ data: JSUint8Array) -> JSUint8Array Generated TypeScript uses native typed array names: processData(data: Uint8Array): Uint8Array Bridging is reference-based (passes JSObject ID, no data copying). Follows the existing JSPromise pre-seeding pattern.
90abc67 to
ce4242a
Compare
Member
Author
|
@MaxDesiatov docs added 🫡 |
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
Add
JSTypedArray<T>and convenience typealiases (JSUint8Array,JSFloat32Array, etc.) as recognized BridgeJS types. Users can now use typed arrays directly in@JSfunction signatures to get native TypedArray types in the generated TypeScript declarations.Both the generic form and typealiases work:
Generated TypeScript:
Bridging is reference-based — passes the JSObject ID across the boundary with no data copying. The TypedArray lives on the JS heap. This follows the same pattern as
JSPromise, which is already pre-seeded as a known BridgeJS type.1.
JSTypedArray.swift— 8 convenience typealiases:JSInt8Array,JSUint8Array,JSInt16Array,JSUint16Array,JSInt32Array,JSUint32Array,JSFloat32Array,JSFloat64Array.2.
SwiftToSkeleton.swift— Pre-seed typed array types in the type resolver (same asJSPromise). RecognizeJSTypedArray<T>generic form via element name → typealias mapping.3.
BridgeJSLink.swift— Map Swift typealias names to JS TypedArray constructor names intsType(e.g.,JSUint8Array→Uint8Array).4.
TS2Swift/processor.js— Map TypeScript TypedArray types to Swift typealiases in the TS importer, preventing import of the full TypedArray API surface from TypeScript's stdlib.5. E2e tests —
JSTypedArrayTests.swift+JSTypedArrayTests.mjswith round-trip tests for Uint8Array, Float32Array, Float64Array, Int32Array from both Swift and JS sides.