Skip to content

BridgeJS: Allow extensions to contain types - #803

Merged
krodak merged 4 commits into
swiftwasm:mainfrom
wfltaylor:extension-types
Aug 17, 2026
Merged

BridgeJS: Allow extensions to contain types#803
krodak merged 4 commits into
swiftwasm:mainfrom
wfltaylor:extension-types

Conversation

@wfltaylor

@wfltaylor wfltaylor commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Currently, you can write this:

@JS enum Change {
    case update(Update)
    case delete

    @JS struct Update {
        let contents: String
    }
}

but not this (which actually emitted broken generated code):

@JS enum Change {
    case update(Update)
    case delete
}

extension Change {
    @JS struct Update {
        let contents: String
    }
}

This PR removes this limitation, so you can define @JS types in extensions.

@wfltaylor

Copy link
Copy Markdown
Contributor Author

I’ve pushed a commit to fix an existing .d.ts code-generation issue that the new tests triggered.

@krodak krodak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three inline findings. The pre-existing relative qualified-name issue is tracked separately in #805.

Comment thread Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Comment thread Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift
Comment thread Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift
}
if let components = qualifiedComponents(from: type) {
if let components = type.qualifiedComponents {
return lookupType(fullyQualified: components)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, extension scoping now handles unqualified names, but relative qualified names such as Shelf.Divider are still treated as root-qualified. An @JS method using that spelling is omitted from the skeleton instead of resolving it as Library.Shelf.Divider.

This behavior already exists before this PR, so I opened #805 to follow it separately rather than treating it as part of this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open up PR for #805 after this one is merged

@krodak
krodak merged commit 7a7a70a into swiftwasm:main Aug 17, 2026
16 checks passed
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.

2 participants