Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swiftwasm/JavaScriptKit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.50.1
Choose a base ref
...
head repository: swiftwasm/JavaScriptKit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.50.2
Choose a head ref
  • 6 commits
  • 15 files changed
  • 1 contributor

Commits on Apr 9, 2026

  1. BridgeJS: Emit static methods and properties on namespaced class entries

    The TypeScript `.d.ts` namespace-entry builder for `@JS(namespace:)`
    classes only emitted the constructor, silently dropping any
    `@JS static func` or `@JS static var` declared on the class. The
    equivalent path for non-namespaced classes
    (`renderExportedClass` → `dtsExportEntryPrinter`) iterates
    `klass.methods.filter(\.effects.isStatic)` and the static subset of
    `klass.properties`, so the output mismatched between the two paths.
    
    The generated JS class still carries the static members via
    `declarationPrefixKeyword: "static"` in `renderExportedClass`, and the
    namespace tree references it by symbol, so the JavaScript runtime
    works. TypeScript consumers, however, see an incomplete type and cannot
    call the static factory through `typeof MyNamespace.MyClass` without
    a hand-written augmentation.
    
    Mirror the non-namespaced path inside the `renderClassEntry` closure in
    `generateTypeScript` so namespaced classes emit their static methods
    and static properties alongside `new(...)`.
    
    Extended `Namespaces.swift` to exercise the codepath by adding a
    static factory and a static readonly property on the existing
    `__Swift.Foundation.Greeter` class. The Namespaces snapshot set
    captures the fixed output.
    krodak committed Apr 9, 2026
    Configuration menu
    Copy the full SHA
    6d2c070 View commit details
    Browse the repository at this point in the history
  2. BridgeJS: Consolidate namespaced and non-namespaced class DTS entry r…

    …endering
    
    The `renderClassEntry` closure passed to
    `buildHierarchicalExportsType` manually rebuilt the same
    `ClassName: { new(...); staticMethod(); ... }` block that
    `renderExportedClass` already produces as its `dtsExportEntry` return
    value. The two paths had to be kept in sync by hand.
    
    Replace the inline closure with a direct call to `renderExportedClass`
    that discards the JS and DTS-type outputs and returns only the
    `dtsExportEntry` slice. This makes the class namespace entry for
    namespaced and non-namespaced classes identical by construction.
    
    Thread `throws` through `buildHierarchicalExportsType`,
    `populateTypeScriptExportLines`, and `generateTypeScript` to
    accommodate the fact that `renderExportedClass` is throwing. Hoist the
    `buildHierarchicalExportsType` call out of the `printer.indent` closure
    so the `try` expression is in a throwing context.
    krodak committed Apr 9, 2026
    Configuration menu
    Copy the full SHA
    9a56b28 View commit details
    Browse the repository at this point in the history
  3. BridgeJS: Add e2e test for static method and property on namespaced c…

    …lass
    
    Extends the existing `__Swift.Foundation.UUID` class (which already
    has an `@JS init` and an `@JS func`) with a static factory
    `fromValue(_:)` and a static readonly property `placeholder`, then
    asserts both are reachable via `exports.__Swift.Foundation.UUID.fromValue`
    and `exports.__Swift.Foundation.UUID.placeholder` in `prelude.mjs`.
    
    This is the e2e counterpart to the snapshot regression added in the
    previous commit — it proves the generated JavaScript actually routes
    calls to the correct static thunks at runtime, not just that the
    `.d.ts` types are well-formed.
    krodak committed Apr 9, 2026
    Configuration menu
    Copy the full SHA
    d1ed185 View commit details
    Browse the repository at this point in the history
  4. BridgeJS: Avoid double-rendering namespaced class DTS export entries

    `renderExportedClass` was being called twice for every namespaced class:
    once in `collectLinkData` (to produce the JS body and instance
    interface) and once more inside the `renderClassEntry` closure (to
    produce the export-entry for `buildHierarchicalExportsType`), with the
    JS and instance-interface outputs discarded on the second call.
    
    Store the `dtsExportEntry` slice in `LinkData.namespacedClassDtsExportEntries`
    during the single `collectLinkData` pass, keyed by class name. The
    `renderClassEntry` closure is now a non-throwing dictionary lookup, so
    `buildHierarchicalExportsType`, `populateTypeScriptExportLines`, and
    `generateTypeScript` revert to non-throwing.
    krodak committed Apr 9, 2026
    Configuration menu
    Copy the full SHA
    575b2bf View commit details
    Browse the repository at this point in the history
  5. BridgeJS: Fix static property call expression for namespaced classes

    Static properties on `@JS(namespace:)` classes used
    `property.callName()` to build the Swift call expression. That method
    consults `property.staticContext`, which is stored as
    `.className(abiName)` (e.g. `__Swift_Foundation_UUID`), and emits
    `\(abiName).\(propertyName)`. The ABI-mangled name is not a valid Swift
    identifier so the generated thunk failed to compile.
    
    Static methods were unaffected because `renderSingleExportedMethod`
    passes `klass.swiftCallName` directly.
    
    Fix `PropertyRenderingContext.callName(for:)` for the `.classStatic`
    case to bypass `property.callName()` and build the expression directly
    from `klass.swiftCallName`. This preserves the ABI symbol name
    (which still comes through `context.className` → `klass.abiName` →
    `property.getterAbiName(className:)`) while producing a valid Swift
    call expression in the thunk body.
    
    Also remove the now-unnecessary comment from `prelude.mjs` that
    described what the test was checking (the assertion itself is
    self-explanatory).
    krodak committed Apr 9, 2026
    Configuration menu
    Copy the full SHA
    57c1fd8 View commit details
    Browse the repository at this point in the history
  6. Merge pull request #717 from PassiveLogic/kr/fix-class-static-method-ts

    BridgeJS: Emit static methods and properties on namespaced class entries
    krodak authored Apr 9, 2026
    Configuration menu
    Copy the full SHA
    46182e2 View commit details
    Browse the repository at this point in the history
Loading