Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Repo Assist] [TypeScript] Fix static class members not re-declaring class-level type parameters (fixes #3504)#4533

Draft
github-actions[bot] wants to merge 1 commit into
main from
repo-assist/fix-issue-3504-static-member-type-params-88adf7f9c959c867
Draft

[Repo Assist] [TypeScript] Fix static class members not re-declaring class-level type parameters (fixes #3504) #4533
github-actions[bot] wants to merge 1 commit into
main from
repo-assist/fix-issue-3504-static-member-type-params-88adf7f9c959c867

Conversation

@github-actions

@github-actions github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

🤖 This pull request was created by Repo Assist, an automated AI assistant.

Summary

Fixes a TypeScript validity bug where static class members that use class-level type parameters produce TypeScript errors because the type parameters are not re-declared on the static method.

Closes #3504

Root Cause

In getMemberArgsAndBody (Fable2Babel.fs), the declaredTypeParams list controls which type parameters appear in the TypeScript method signature. For attached (class) members, the code previously excluded class-level type parameters (entGenParams) for all cases — both static and instance.

This is correct for instance methods: TypeScript instance methods can access class type params implicitly. But static methods cannot — TypeScript requires them to explicitly re-declare any class type params they use in their signature.

Example (before):

class MyList<TRaw> {
 instance(xs: FSharpList<TRaw>): void { ... } // OK - TRaw inherited
 static checkLength(xs: FSharpList<TRaw>): int32 { ... } // ERROR: TRaw undeclared
}

Example (after):

class MyList<TRaw> {
 instance(xs: FSharpList<TRaw>): void { ... } // OK - TRaw inherited
 static checkLength<TRaw>(xs: FSharpList<TRaw>): int32 { ... } // OK - TRaw declared
}

The Fix

In getMemberArgsAndBody, when computing declaredTypeParams for an attached member, check if kind = Attached(isStatic = true). If so, include entGenParams (the class-level type params) in declaredTypeParams alongside the method's own generic parameters.

The change is minimal — ~5 lines changed in getMemberArgsAndBody. No impact on JavaScript output (the typeParams path is TypeScript-only).

Generated by Repo Assist · くろまる 13.8M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

...fixes #3504)
Static methods in TypeScript cannot inherit class-level type parameters implicitly
(unlike instance methods). When a static method uses a class type parameter in its
signature, TypeScript requires it to be re-declared on the static method itself.
Previously, getMemberArgsAndBody always excluded entGenParams from declaredTypeParams
for all attached (class) members, both static and instance. Instance methods are correct
because TypeScript can access class type params implicitly. But static methods must
re-declare any class type params they use.
The fix adds a check for Attached(isStatic = true): in that case, entGenParams is
included in declaredTypeParams so the type params appear on the static method signature.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation Automated changes repo-assist Created by Repo Assist labels Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

automation Automated changes repo-assist Created by Repo Assist

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Adding generic static member in a class emits invalid TypeScript

0 participants

AltStyle によって変換されたページ (->オリジナル) /