Skip to content

Conversation

@krodak
Copy link
Member

@krodak krodak commented Jan 30, 2026

Introduction

Adds UInt type support to BridgeJS, allowing Swift functions using UInt parameters and return values to be exported to JavaScript.

Motivation: Enable developers to use existing Swift code with UInt types without requiring modifications to use Int instead.

Example

@JS func processUnsigned(_ value: UInt) -> UInt {
    return value * 2
}

TypeScript:

export function processUnsigned(value: number): number;

Implementation Notes

  • UInt maps to number in TypeScript (same as Int)
  • Uses bitwise conversion to preserve the full UInt32 range (0 to 4,294,967,295)
  • On the JS side, return values use >>> 0 to convert signed Int32 back to unsigned

This approach is consistent with how Int supports its full range (-2^31 to 2^31-1) — UInt also supports its full range. But if we'd rather just not handle this case and return .identity, just let me know.

Testing

  • Added UInt to primitive type snapshot tests
  • Added E2E round-trip tests including edge case 4294967295 (max UInt32)

@krodak krodak self-assigned this Jan 30, 2026
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