The requested changes are too big and content was truncated. Show full diff
@@ -0,0 +1,25 | |||
|
1 | import * as _WidgetBase from "dijit/_WidgetBase"; | |
|
2 | import * as Stateful from "dojo/Stateful"; | |
|
3 | ||
|
4 | export interface IRemovable { | |
|
5 | remove(): void; | |
|
6 | } | |
|
7 | ||
|
8 | type StatefulAttrs<T> = T extends Stateful<infer A> ? A : never; | |
|
9 | ||
|
10 | interface WatchFn { | |
|
11 | <T extends Stateful, K extends keyof StatefulAttrs<T>>( | |
|
12 | target: T, | |
|
13 | prop: K, | |
|
14 | render: (model: StatefulAttrs<T>[K]) => any, | |
|
15 | own?: (obj: IRemovable) => void | |
|
16 | ); | |
|
17 | <W extends _WidgetBase, K extends keyof W>( | |
|
18 | target: W, | |
|
19 | prop: K, | |
|
20 | render: (model: W[K]) => any, | |
|
21 | own?: (obj: IRemovable) => void | |
|
22 | ); | |
|
23 | } | |
|
24 | ||
|
25 | export declare const watch: WatchFn; |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -7,12 +7,12 declare module 'dijit/_Widget' { | |||
|
7 | 7 | } |
|
8 | 8 | |
|
9 | 9 | declare module 'dijit/_WidgetBase' { |
|
10 | type _WidgetBase<A = any> = dijit._WidgetBase<A>; | |
|
10 | type _WidgetBase<E extends { [k in keyof E]: Event } = {}> = dijit._WidgetBase<E & GlobalEventHandlersEventMap>; | |
|
11 | 11 | |
|
12 | 12 | // individual _WidgetBase constructor to keep type parameters |
|
13 | 13 | interface _WidgetBaseConstructor { |
|
14 |
new <A = |
|
|
15 | prototype: _WidgetBase; | |
|
14 | new <A = {}, E extends { [k in keyof E]: Event } = {}>(params?: Partial<_WidgetBase<E> & A>, srcNodeRef?: dojo.NodeOrString): _WidgetBase<E> & dojo._base.DeclareCreatedObject; | |
|
15 | prototype: _WidgetBase<any>; | |
|
16 | 16 | } |
|
17 | 17 | const _WidgetBase: _WidgetBaseConstructor; |
|
18 | 18 | export = _WidgetBase; |
@@ -1961,7 +1961,7 declare namespace dojo { | |||
|
1961 | 1961 | /** |
|
1962 | 1962 | * Watches a property for changes |
|
1963 | 1963 | */ |
|
1964 |
watch(callback: |
|
|
1964 | watch(callback:(prop: keyof any, oldValue: any, newValue: any) => void): WatchHandle; | |
|
1965 | 1965 | watch<K extends keyof T>(name: K, callback: (prop: K, oldValue: T[K], newValue: T[K]) => void): WatchHandle; |
|
1966 | 1966 | } |
|
1967 | 1967 |
@@ -724,7 +724,7 declare module 'dojo/sniff' { | |||
|
724 | 724 | } |
|
725 | 725 | |
|
726 | 726 | declare module 'dojo/Stateful' { |
|
727 |
type Stateful<T = any> = dojo.Stateful< |
|
|
727 | type Stateful<T = any> = dojo.Stateful<T>; | |
|
728 | 728 | const Stateful: dojo.StatefulConstructor; |
|
729 | 729 | export = Stateful; |
|
730 | 730 | } |
@@ -1,4 +1,5 | |||
|
1 |
import Stateful |
|
|
1 | import * as Stateful from "dojo/Stateful"; | |
|
2 | import { StatefulAttrs, watch } from "./traits"; | |
|
2 | 3 | |
|
3 | 4 | interface ScheduleAttrs { |
|
4 | 5 | title: string; |
@@ -18,4 +19,8 const model = new Schedule({duration: 10 | |||
|
18 | 19 | model.get("title"); |
|
19 | 20 | model.get("duration"); |
|
20 | 21 | |
|
21 | model.set("duration", 12); No newline at end of file | |
|
22 | model.set("duration", 12); | |
|
23 | ||
|
24 | watch(model, "duration", v => v); | |
|
25 | ||
|
26 | declare const o : StatefulAttrs<Schedule>; No newline at end of file |
@@ -1,5 +1,5 | |||
|
1 |
import Memory |
|
|
2 |
import Observable |
|
|
1 | import * as Memory from "dojo/store/Memory"; | |
|
2 | import * as Observable from "dojo/store/Observable"; | |
|
3 | 3 | |
|
4 | 4 | interface Schedule { |
|
5 | 5 | |
@@ -16,13 +16,11 const observable = new Observable(store) | |||
|
16 | 16 | |
|
17 | 17 | const mem = new Memory<Schedule>(); |
|
18 | 18 | |
|
19 | (async () => { | |
|
20 |
|
|
|
21 | store.query().forEach(() => {}); | |
|
22 |
|
|
|
23 | const result = await store.query(); | |
|
19 | observable.query().observe(() => { }); | |
|
20 | store.query().forEach(() => { }); | |
|
21 | const total = await store.query().total; | |
|
22 | const result = await store.query(); | |
|
24 | 23 | |
|
25 |
|
|
|
24 | mem.query(); | |
|
26 | 25 | |
|
27 |
|
|
|
28 | })(); No newline at end of file | |
|
26 | mem.add({ duration: 10, title: "Test event" }); |
@@ -1,17 +1,41 | |||
|
1 |
import _WidgetBase |
|
|
1 | import * as _WidgetBase from "dijit/_WidgetBase"; | |
|
2 | import { watch } from "./traits"; | |
|
2 | 3 | |
|
3 | 4 | interface ScheduleWidgetAttrs { |
|
4 | 5 | data: string[]; |
|
5 | 6 | } |
|
6 | 7 | |
|
7 | declare const w0: _WidgetBase<ScheduleWidgetAttrs>; | |
|
8 | interface ScheduleWidgetEvents { | |
|
9 | "scheduled": Event & { | |
|
10 | detail: { | |
|
11 | startDate: Date, | |
|
12 | endDate: Date | |
|
13 | } | |
|
14 | }; | |
|
15 | } | |
|
8 | 16 | |
|
9 | w0.get("data"); | |
|
10 | ||
|
11 | declare class ScheduleWidget extends _WidgetBase { | |
|
17 | declare class ScheduleWidget extends _WidgetBase<ScheduleWidgetAttrs, ScheduleWidgetEvents> { | |
|
12 | 18 | data: string[]; |
|
13 | 19 | } |
|
14 | 20 | |
|
15 | 21 | const w = new ScheduleWidget({title: "Year schedule", data: ["a", "b"] }); |
|
16 | 22 | |
|
17 | w.get("data"); No newline at end of file | |
|
23 | w.get("data"); | |
|
24 | ||
|
25 | w.watch((p, o, n) => [p,o,n]); | |
|
26 | ||
|
27 | w.watch("data", (p, o, n) => [p,o,n]); | |
|
28 | ||
|
29 | watch(w, "title", v => String(v) ); | |
|
30 | watch(w, "data", v => String(v) ); | |
|
31 | ||
|
32 | w.emit("scheduled", { detail: { startDate: new Date(), endDate: new Date()} }); | |
|
33 | ||
|
34 | w.emit("click", {} ); | |
|
35 | ||
|
36 | w.emit("click", {} ); | |
|
37 | ||
|
38 | w.emit("some-extra-event", {}); | |
|
39 | ||
|
40 | w.on("click", e => e); | |
|
41 | w.on("some-extra-event", e => e); |
@@ -5,6 +5,7 | |||
|
5 | 5 | "rootDir": "ts", |
|
6 | 6 | "rootDirs": [ |
|
7 | 7 | "ts", |
|
8 | "typings", | |
|
8 | 9 | "../main/ts" |
|
9 | 10 | ], |
|
10 | 11 | "types": [ |
@@ -12,7 +13,8 | |||
|
12 | 13 | "../main/typings/dojo/modules", |
|
13 | 14 | "../main/typings/dijit/modules" |
|
14 | 15 | ], |
|
15 |
"module": " |
|
|
16 | "module": "ESNext", | |
|
17 | "target": "ESNext" | |
|
16 | 18 | }, |
|
17 | 19 | "include": [ |
|
18 | 20 | "typings/**/*.ts", |
General Comments 0
You need to be logged in to leave comments.
Login now