Skip to content

Interop Gen: Combine Interface and var declarations into class where possible #429

@nikeokoronkwo

Description

@nikeokoronkwo

In a lot of implementations, like the ES2015's collection spec:

interface Map<K, V> {
    clear(): void;
    delete(key: K): boolean;
    forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
    get(key: K): V | undefined;
    has(key: K): boolean;
    set(key: K, value: V): this;
    readonly size: number;
}

interface MapConstructor {
    new (): Map<any, any>;
    new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
    readonly prototype: Map<any, any>;
}
declare var Map: MapConstructor;

This issue is to track such overloading support for combining such types together where possible, which should emit just a Dart interface combining the sub implementations (in this case, MapConstructor and Map). The var declaration will be combined, converting all the properties on its type into static properties.

extension type Map<K extends JSAny, V extends JSAny>._(JSObject _) implements JSObject {
 /** summed up declarations and constructors */
}

(See #388 for more)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions