GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BridgeJS: Support optional @JSClass as exported function parameters by krodak · Pull Request #754 · swiftwasm/JavaScriptKit

Conversation

@krodak

@krodak krodak commented Jun 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Overview

Fixes #751. A @JS exported function taking (or returning) an optional @JSClass such as JSAbortSignal? failed to compile with no exact matches in call to static method 'bridgeJSLiftParameter' for Optional<JSAbortSignal>.

Optional jsObject (incl. @JSClass) parameters now use the direct (isSome, objId) ABI in both directions, matching plain Optional<JSObject> and exported @JS class parameters; only return values use the stack ABI.

1. Export parameters: use the direct ABI. ExportSwift no longer special-cases .nullable(.jsObject), so exported parameters lift via Optional<T>.bridgeJSLiftParameter(isSome, value). Adds the missing Optional<_JSBridgedClass>.bridgeJSLiftParameter(isSome, objId) and bridgeJSLowerReturn() so optional @JSClass values round-trip as both parameters and return values.

2. Import parameters: align to the direct ABI. loweringParameterInfo already lowered optional jsObject import parameters as direct (isSome, value), but the JS lift still popped the object id off the stack that Swift never pushed, throwing ReferenceError: Attempted to use invalid reference undefined for a non-nil value. The JS lift now reads the object id directly, matching the extern.

A new optionalParameterUsesStackABI keeps the stack ABI only for the return direction of optional jsObject.

Tests

  • Export direction: end-to-end runtime test passing an optional imported @JSClass directly as an exported function parameter and return value (present and null cases), plus snapshot coverage for optional JSObject? and @JSClass?.
  • Import direction: end-to-end runtime test passing an optional JSObject? into an imported JS function (present and null cases), plus updated snapshot coverage for the optional @JSClass? import parameter.
  • Regenerated in-package snapshots and the AoT-committed bindings. Snapshot suites, the BridgeJS TypeScript declaration check, and the full wasm test suite pass.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krodak krodak self-assigned this Jun 3, 2026
@krodak
krodak requested a review from kateinoigakukun June 3, 2026 11:22
@kateinoigakukun

kateinoigakukun commented Jun 8, 2026

Copy link
Copy Markdown
Member

Sorry, I'm still reviewing this, so please give me some more time 🙇

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kateinoigakukun
kateinoigakukun requested changes Jun 9, 2026
View reviewed changes
Comment thread Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift Resolved

Uh oh!

There was an error while loading. Please reload this page.

@krodak
BridgeJS: Support optional @jsclass as exported function parameters
c93a031
@krodak
krodak force-pushed the kr/fix-optional-jsclass-param branch from 5dbbd02 to c93a031 Compare June 9, 2026 16:03
@krodak
BridgeJS: Pass optional jsObject import parameters via direct ABI
83098c2
kateinoigakukun
kateinoigakukun approved these changes Jun 9, 2026
View reviewed changes
@krodak
krodak merged commit 9706c4c into swiftwasm:main Jun 9, 2026
13 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kateinoigakukun kateinoigakukun kateinoigakukun approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@krodak krodak

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

BridgeJS: Optional @JSClass parameter fails lift/lower for generated bindings

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@krodak @kateinoigakukun
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.