diff --git a/dojo-typings/build.gradle b/dojo-typings/build.gradle --- a/dojo-typings/build.gradle +++ b/dojo-typings/build.gradle @@ -39,7 +39,9 @@ typescript { configureTsTest { compilerOptions { - types = ["../main/typings/dojo/modules","../main/typings/dijit/modules"]; + types = ["../main/typings/dojo/modules","../main/typings/dijit/modules"] + module = "ESNext" + it.target = "ESNext" } } 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 @@ -549,6 +549,10 @@ declare namespace dijit { onClose(): boolean; } + type Props = { + [k in Exclude] : T[k] extends (...args: any) => any ? never: k; + }[ keyof T]; + interface _WidgetBase { /** * Used across all instances a hash to cache attribute names and their getter @@ -569,7 +573,7 @@ declare namespace dijit { */ _changeAttrValue(name: string, value: any): this; - get(name: K): this[K]; + get(name: K): this[K]; /** * Helper function to set new value for specified property, and call handlers @@ -591,15 +595,15 @@ declare namespace dijit { /** * Set a property on a Stateful instance */ - set(name: K, value: this[K]): this; - set(name: K, ...values: this[K]): this; - set(values: Partial): this; + set(name: K, value: this[K]): this; + set(name: K, ...values: V): this; + set(values: {[p in K]: this[p]}): this; /** * Watches a property for changes */ watch(callback: (prop: K, oldValue: any, newValue: any) => void): dojo.WatchHandle; - watch(name: K, callback: (prop: K, oldValue: this[K], newValue: this[K]) => void): dojo.WatchHandle; + watch>(name: K, callback: (prop: K, oldValue: this[K], newValue: this[K]) => void): dojo.WatchHandle; } type EventInitArgs = { diff --git a/dojo-typings/src/main/typings/dijit/form.d.ts b/dojo-typings/src/main/typings/dijit/form.d.ts --- a/dojo-typings/src/main/typings/dijit/form.d.ts +++ b/dojo-typings/src/main/typings/dijit/form.d.ts @@ -8,7 +8,7 @@ declare namespace dijit { [prop: string]: any; } - interface ConstrainedValueFunction { + interface ConstrainedValueFunction { /** * Returns a value that has been constrained by the constraints * @param value The value to constrain @@ -18,7 +18,7 @@ declare namespace dijit { (value: V, constraints: C): T; } - interface ConstrainedValidFunction { + interface ConstrainedValidFunction { /** * Returns true if the value is valid based on the constraints, otherwise * returns false. @@ -29,7 +29,7 @@ declare namespace dijit { (value: any, constraints: C): boolean; } - interface ConstraintsToRegExpString { + interface ConstraintsToRegExpString { /** * Takes a set of constraints and returns a RegExpString that can be used * to match values against @@ -46,7 +46,7 @@ declare namespace dijit { /* dijit/form/_AutoCompleterMixin */ /* tslint:disable:class-name */ - interface _AutoCompleterMixin extends _SearchMixin { + interface _AutoCompleterMixin extends _SearchMixin { /** * This is the item returned by the dojo/store/api/Store implementation that * provides the data for this ComboBox, it's the currently selected item. @@ -179,7 +179,7 @@ declare namespace dijit { /* dijit/form/_ComboBoxMenu */ - interface _ComboBoxMenu extends _WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin { + interface _ComboBoxMenu extends _WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin { templateString: string; baseClass: string; @@ -219,12 +219,12 @@ declare namespace dijit { } interface _ComboBoxMenuConstructor extends _WidgetBaseConstructor<_ComboBoxMenu> { - new (params: Object, srcNodeRef: dojo.NodeOrString): _ComboBoxMenu; + new (params: Object, srcNodeRef: dojo.NodeOrString): _ComboBoxMenu; } /* dijit/form/_ComboBoxMenuMixin */ - interface _ComboBoxMenuMixin { + interface _ComboBoxMenuMixin { /** * Holds "next" and "previous" text for paging buttons on drop down */ @@ -468,7 +468,7 @@ declare namespace dijit { disabled?: boolean; } - interface _FormSelectWidget extends _FormValueWidget { + interface _FormSelectWidget extends _FormValueWidget { /** * Whether or not we are multi-valued */ @@ -862,7 +862,7 @@ declare namespace dijit { /* dijit/form/_SearchMixin */ - interface _SearchMixin { + interface _SearchMixin { /** * Argument to data provider. * Specifies maximum number of search results to return per query @@ -1006,7 +1006,7 @@ declare namespace dijit { /* dijit/form/_TextBoxMixin */ - interface _TextBoxMixin { + interface _TextBoxMixin { /** * Removes leading and trailing whitespace if true. Default is false. */ @@ -1163,18 +1163,18 @@ declare namespace dijit { /* dijit/form/ComboBox */ - interface ComboBox extends ValidationTextBox, ComboBoxMixin { + interface ComboBox extends ValidationTextBox, ComboBoxMixin { // set(name: string, value: any): this; // set(values: Object): this; } - interface ComboBoxConstructor extends _WidgetBaseConstructor> { - new (params: Object, srcNodeRef: dojo.NodeOrString): ComboBox; + interface ComboBoxConstructor extends _WidgetBaseConstructor> { + new (params: Object, srcNodeRef: dojo.NodeOrString): ComboBox; } /* dijit/form/ComboBoxMixin */ - interface ComboBoxMixin extends _HasDropDown<_ComboBoxMenu>, _AutoCompleterMixin { + interface ComboBoxMixin extends _HasDropDown<_ComboBoxMenu>, _AutoCompleterMixin { /** * Dropdown widget class used to select a date/time. @@ -1204,7 +1204,7 @@ declare namespace dijit { buildRendering(): void; } - interface ComboBoxMixinConstructor extends _WidgetBaseConstructor> { } + interface ComboBoxMixinConstructor extends _WidgetBaseConstructor> { } /* dijit/form/CurrencyTextBox */ @@ -1840,7 +1840,7 @@ declare namespace dijit { (isFocused?: boolean): boolean; } - interface ValidationTextBox extends TextBox { + interface ValidationTextBox extends TextBox { templateString: string; required: boolean; promptMessage: string; diff --git a/dojo-typings/src/main/typings/dijit/layout.d.ts b/dojo-typings/src/main/typings/dijit/layout.d.ts --- a/dojo-typings/src/main/typings/dijit/layout.d.ts +++ b/dojo-typings/src/main/typings/dijit/layout.d.ts @@ -204,7 +204,7 @@ declare namespace dijit { * Note that the initialization parameter / argument to set("content", ... * can be a String, DomNode, Nodelist, or _Widget. */ - content: dojo.ContentSetterContent | dijit._Widget; + content: any; /** * Extract visible content from inside of ` .... ` 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 @@ -283,7 +283,7 @@ declare module 'dijit/form/ComboBox' { } declare module 'dijit/form/ComboBoxMixin' { - type ComboBoxMixin = dijit.form.ComboBoxMixin; + type ComboBoxMixin = dijit.form.ComboBoxMixin; const ComboBoxMixin: dijit.form.ComboBoxConstructor; export = ComboBoxMixin; } @@ -343,7 +343,7 @@ declare module 'dijit/form/HorizontalSli } declare module 'dijit/form/MappedTextBox' { - type MappedTextBox = dijit.form.MappedTextBox; + type MappedTextBox = dijit.form.MappedTextBox; const MappedTextBox: dijit.form.MappedTextBoxConstructor; export = MappedTextBox; } @@ -373,7 +373,7 @@ declare module 'dijit/form/RangeBoundTex } declare module 'dijit/form/Select' { - type Select = dijit.form.Select; + type Select = dijit.form.Select; const Select: dijit.form.SelectConstructor; export = Select; } @@ -403,7 +403,7 @@ declare module 'dijit/form/ToggleButton' } declare module 'dijit/form/ValidationTextBox' { - type ValidationTextBox = dijit.form.ValidationTextBox; + type ValidationTextBox = dijit.form.ValidationTextBox; const ValidationTextBox: dijit.form.ValidationTextBoxConstructor; export = ValidationTextBox; } diff --git a/dojo-typings/src/test/ts/_WidgetTests.ts b/dojo-typings/src/test/ts/_WidgetTests.ts --- a/dojo-typings/src/test/ts/_WidgetTests.ts +++ b/dojo-typings/src/test/ts/_WidgetTests.ts @@ -14,14 +14,32 @@ interface ScheduleWidgetEvents { }; } -declare class ScheduleWidget extends _WidgetBase { +class ScheduleWidget extends _WidgetBase { data: string[]; + + _onClick() { + this.set("data", "", ""); + + const t = this.get("title"); + this.set({ + data: ["",""] + }); + } + + render(){ + watch(this, "title", v => String(v) ); + } } const w = new ScheduleWidget({title: "Year schedule", data: ["a", "b"] }); w.get("data"); +w.set("data", "a","b"); +w.set({ + data: ["a", "b"] +}); + w.watch((p, o, n) => [p,o,n]); w.watch("data", (p, o, n) => [p,o,n]);