glutinum-org / cli

Home Page:https://glutinum.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support static method on class

MangelMaxime opened this issue · comments

TypeScript documentation:

export class Class {
    static methodA(): void;

    static methodB(arg1 : string, arg2: string): void;
}

translates into

[<AllowNullLiteral>]
[<InterfaceAttribute>]
type Class =
    static member inline methodA () : unit =
        emitJsExpr () $$"""
import { Class } from "module";
Class.methodA()"""

    static member inline methodB (arg1 : string, arg2: string) : unit =
        emitJsExpr (arg1, arg2) $$"""
import { Class } from "module";
Class.methodB($0, $1)"""

Code tested with this reproduction:

CleanShot 2024-03-25 at 16 50 19

Example of npm package using this features:

Leaflet

Currently the code below results in a maximum call stack size exceeded

export class Class {
    static extend(props: any): { new (...args: any[]): any } & typeof Class;
}