BridgeJS: Emit static members in declare global class declarations#772
Merged
krodak merged 1 commit intoJun 23, 2026
Merged
Conversation
The `declare global { namespace ... }` class stub rendered every method
without `static` and filtered properties to instance-only, so a `@JS static
func` on a namespaced class was typed as an instance method and a `@JS
static var` was omitted from the generated `.d.ts`.
This was a type-only defect: the emitted JavaScript already exposes these
members statically (and the class's namespace export entry types them
correctly), so only TypeScript consumers were affected. Split static and
instance members in this path: emit static methods with `static` and
include static properties.
This has been incorrect since the global namespace class stub was
introduced, not a regression. The `Namespaces.Global` snapshot already
exercises a namespaced class with `static func`/`static var` but had
recorded the wrong output, so it is updated to the corrected declarations.
kateinoigakukun
approved these changes
Jun 23, 2026
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
Static members of a globally-exposed
@JS(namespace:)class were rendered incorrectly in the generateddeclare global { namespace ... }TypeScript declarations: every method was emitted withoutstatic, and properties were filtered to instance-only. As a result a@JS static funcwas typed as an instance method and a@JS static varwas dropped from the.d.tsentirely.This is a type-only defect. The emitted JavaScript already exposes these members statically (and the class's namespace export entry types them correctly), so the runtime behavior is unaffected and only TypeScript consumers were impacted: static access such as
MyNamespace.MyClass.makeDefault()would not type-check even though the call works at runtime. We found it now, as we havetsc --noEmitcheck over consumer code.The fix splits static and instance members in this path, emitting static methods with
staticand including static properties (withstatic/readonlyas appropriate).Before / after