Conversation
krodak
force-pushed
the
kr/export-type-names
branch
from
September 15, 2026 13:17
27272e9 to
1711b35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Extend the
@JS("name")support for functions, methods, and properties added in swiftwasm/JavaScriptKit#801 to exported classes, structs, enums, and protocols. Swift wrappers can keep implementation-specific names while presenting a cleaner JavaScript and TypeScript API.JavaScript constructs this class through
new exports.Counter(1), and TypeScript uses the generatedCounterinterface. Swift still usesInternalCounter.The skeleton keeps Swift identities and ABI namespaces separate from public names and namespace paths. The linker uses public names in constructors, signatures, callbacks, default arguments, enum value objects, and nested exports. Renaming a parent does not change descendant Swift thunk symbols.
Nested types also inherit an enclosing class or struct's explicit namespace, matching namespace enums. This applies to unrenamed declarations too; nested types cannot specify their own namespace.
A name override cannot be combined with
@JS(as:): renaming changes the API spelling, not its representation or memory-management semantics. Constructors remain instance-owned, and pointer-identity behavior is unchanged.Cross-declaration collision diagnostics intentionally remain out of scope, matching existing export-name behavior. I'm happy to add them if needed.
Test Plan
./Utilities/format.swiftswift test --package-path ./Plugins/BridgeJS --disable-experimental-prebuilts --scratch-path <isolated-build>with the default SwiftSyntax version andBRIDGEJS_OVERRIDE_SWIFT_SYNTAX_VERSIONset to601.0.0,602.0.0, and603.0.0, each in a separate build directory../Utilities/bridge-js-generate.shnpm run check:bridgejs-dtsnpm run test:runtimemake unittest BUILD_SYSTEM=native SWIFT_SDK_ID=swift-6.3.1-RELEASE_wasm