Re: Subclassing a GObject in Typescript



I want to make ts-for-gjs work with registerClass(), but as a Typescript beginner I would appreciate some advice. I'm proposing to make it add these globals to GObject.d.ts:

export function registerClass(klass: Object): Object
export declare const interfaces: unique symbol
export declare const properties: unique symbol
export declare const requires: unique symbol
export declare const signals: unique symbol

Does that look OK? I'm not 100% sure that Object is the most appropriate type to use for registerClass' parameter and return value.

GObject.Object needs this pseudo-constructor:

    _init(params?:object): void

but is the base class the only one that needs that, or is it overridden in all subclasses?

When registerClass() is called, it adds the equivalent of these static members to the class being registered:

    static [interfaces]?: any[]
    static [properties]?: object
    static [requires]?: any[]
    static [signals]?: object

Seeing as they're added dynamically to 3rd party classes, but aren't present in the introspected classes, I don't think we can actually get ts-for-gjs to do anything about them. Any ideas on how these could be made convenient to use in Typescript?

--
TH



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]