Skip to content

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

@kateinoigakukun

Description

@kateinoigakukun

Summary

BridgeJS code generation fails when a @JS exported function takes an optional @JSClass parameter (e.g. JSAbortSignal?).

Repro

In a BridgeJS-exported Swift API:

@JSClass
public struct JSAbortSignal {
    @JSFunction public func addEventListener(type: String, listener: JSTypedClosure<() -> Void>) throws(JSException)
}

@JS
public final class JSCanvasSession {
    @JS
    public func recognizeText(pageId: String, languageCode: String, abortSignal: JSAbortSignal?) async throws(JSException) -> String {
        return "{}"
    }
}

Run BridgeJS AoT generation + build.

Actual

Generated code fails to compile in Generated/BridgeJS.swift with optional lift/lower errors for Optional<JSAbortSignal>, e.g.:

  • no exact matches in call to static method 'bridgeJSLiftParameter'
  • candidates require Wrapped == JSObject or protocol conformances not satisfied by JSAbortSignal

Expected

Optional @JSClass params should be supported, or codegen should emit a clear diagnostic that this shape is unsupported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions