Skip to content

[BridgeJS] Generated JSTypedClosure initializer is always internal #709

Description

@sliemeobn

I have a type like this in a target:

@JSClass(jsName: "Document")
public struct JSDocument {
     // ...
    @JSFunction public func addEventListener(_ type: String, _ listener: JSTypedClosure<(JSEvent) -> Void>) throws(JSException)
    @JSFunction public func removeEventListener(_ type: String, _ listener: JSTypedClosure<(JSEvent) -> Void>) throws(JSException)
}

unfortunately, I cannot directly initialize a JSTypedClosure<(JSEvent) -> Void> in another target, because the generated init is internal.

not sure how to best solve this, but currently you'll need to manually add some public/package function to actually be able to make such a closure.

Activity

  1. kateinoigakukun commented on Mar 25, 2026

    @kateinoigakukun
    Member

    I think we can make the synthesized initializers public when the closure appears in public surfaces

  2. matthewa26 commented on Apr 25, 2026

    @matthewa26
    Contributor

    I just opened PR #727 as a proposed fix. For this, the synthesized init now picks up the access level from the surrounding class or function. I'd be happy to adjust the approach if desired.

  3. krodak commented on Apr 30, 2026

    @krodak
    Member

    @sliemeobn you can retest now on 0.51.0 🙏🏻

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions