# HG changeset patch # User cin # Date 2021-08-30 16:13:10 # Node ID d55cc09feba186557f1575fc65ccfab13714a698 # Parent ab570232df7d7ff7943535b30b7dc1f12e3eb7a7 updated _WidgetBase typings, added support for the generic type parameter to the constructor diff --git a/dojo-typings/build.gradle b/dojo-typings/build.gradle --- a/dojo-typings/build.gradle +++ b/dojo-typings/build.gradle @@ -13,6 +13,7 @@ npm { sources { main { me -> ts { + // to check typings with the compiler srcDir me.typings } } diff --git a/dojo-typings/src/main/typings/dijit/dijit.d.ts b/dojo-typings/src/main/typings/dijit/dijit.d.ts --- a/dojo-typings/src/main/typings/dijit/dijit.d.ts +++ b/dojo-typings/src/main/typings/dijit/dijit.d.ts @@ -550,7 +550,7 @@ declare namespace dijit { } /* dijit/_WidgetBase */ - interface _WidgetBase extends dojo.Stateful, Destroyable { + interface _WidgetBase extends dojo.Stateful, Destroyable { /** * A unique, opaque ID string that can be assigned by users or by the diff --git a/dojo-typings/src/main/typings/dijit/modules.d.ts b/dojo-typings/src/main/typings/dijit/modules.d.ts --- a/dojo-typings/src/main/typings/dijit/modules.d.ts +++ b/dojo-typings/src/main/typings/dijit/modules.d.ts @@ -7,8 +7,14 @@ declare module 'dijit/_Widget' { } declare module 'dijit/_WidgetBase' { - type _WidgetBase = dijit._WidgetBase; - const _WidgetBase: dijit._WidgetBaseConstructor<_WidgetBase>; + type _WidgetBase = dijit._WidgetBase; + + // individual _WidgetBase constructor to keep type parameters + interface _WidgetBaseConstructor { + new (params?: Partial<_WidgetBase & A>, srcNodeRef?: dojo.NodeOrString): _WidgetBase & dojo._base.DeclareCreatedObject; + prototype: _WidgetBase; + } + const _WidgetBase: _WidgetBaseConstructor; export = _WidgetBase; } diff --git a/dojo-typings/src/test/ts/StoreTests.ts b/dojo-typings/src/test/ts/StoreTests.ts --- a/dojo-typings/src/test/ts/StoreTests.ts +++ b/dojo-typings/src/test/ts/StoreTests.ts @@ -1,8 +1,9 @@ +import Memory = require("dojo/store/Memory"); import Observable = require("dojo/store/Observable"); interface Schedule { - id: string; + id?: string; title: string; @@ -13,9 +14,15 @@ declare const store: dojo.store.api.Stor const observable = new Observable(store); +const mem = new Memory(); + (async () => { observable.query().observe(() => {}); store.query().forEach(() => {}); const total = await store.query().total; const result = await store.query(); + + mem.query(); + + mem.add({duration: 10, title: "Test event"}); })(); \ No newline at end of file diff --git a/dojo-typings/src/test/ts/_WidgetTests.ts b/dojo-typings/src/test/ts/_WidgetTests.ts new file mode 100644 --- /dev/null +++ b/dojo-typings/src/test/ts/_WidgetTests.ts @@ -0,0 +1,17 @@ +import _WidgetBase = require("dijit/_WidgetBase"); + +interface ScheduleWidgetAttrs { + data: string[]; +} + +declare const w0: _WidgetBase; + +w0.get("data"); + +declare class ScheduleWidget extends _WidgetBase { + data: string[]; +} + +const w = new ScheduleWidget({title: "Year schedule", data: ["a", "b"] }); + +w.get("data"); \ No newline at end of file