◐ Shell
clean mode source ↗

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

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.