Skip to content

Commit b0d6f69

Browse files
committed
work to extend the definitions for WinJS and WinRT
1 parent 1fd738c commit b0d6f69

File tree

2 files changed

+147
-50
lines changed

2 files changed

+147
-50
lines changed

winjs/winjs.d.ts

Lines changed: 121 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,55 @@ and limitations under the License.
1515

1616
declare module WinJS {
1717
function strictProcessing(): void;
18+
19+
export module Application {
20+
export var onsettings: EventListener;
21+
}
22+
1823
module Binding {
1924
function as(data: any): any;
20-
class List {
21-
constructor(data?: any[]);
22-
public push(item: any): any;
23-
public indexOf(item: any): number;
24-
public splice(start: number, howMany?: number, item?: any[]): any[];
25-
public createFiltered(predicate: (x: any) => boolean): List;
26-
public createGrouped(keySelector: (x: any) => any, dataSelector: (x:any) => any, groupSorter: (left:any, right:any) => number): List;
27-
public groups: any;
25+
function processAll(rootElement?: any, dataContext?: any, skipRoot?: boolean, bindingCache?: any): any;
26+
function define(data: any): any;
27+
function expandProperties(data: any): any;
28+
function converter(method: any): any;
29+
30+
export var optimizeBindingReferences: boolean;
31+
export var mixin;
32+
export var bind;
33+
export var oneTime;
34+
35+
export function initializer(customInit): any;
36+
export var setAttribute;
37+
38+
class List<T> {
39+
constructor(data?: T[], options?: { binding: boolean; proxy: boolean; });
40+
public push(item: T): number;
41+
public indexOf(item: T, fromIndex?: number): number;
42+
public splice(start: number, howMany?: number, ...items: T[]): T[];
43+
public createFiltered(predicate: (x: T) => boolean): List<T>;
44+
public createGrouped<U>(keySelector: (x: T) => string, dataSelector: (x:T) => U, groupSorter: (left:string, right:string) => number): List<T>;
45+
public createSorted(sorter: (left:T, right:T) => number);
46+
public groups: List<any>;
2847
public dataSource: any;
29-
public getAt(index: number): any;
30-
public createSorted(sorter: (left, right) => number);
31-
public forEach(callback: (val: any, index: number, array: any[]) => void, thisArg?: any);
32-
public every(callback: (val: any, index: number, array: any[]) => boolean, thisArg?: any): boolean;
48+
public getAt(index: number): T;
49+
public forEach(callback: (val: T, index: number, array: T[]) => void, thisArg?: any);
50+
public every(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
3351
public join(separator: string): string;
34-
public map(callback: (val: any, index: number, array: any[]) => any, thisArg?: any): any[];
52+
public map<U>(callback: (val: T, index: number, array: T[]) => U, thisArg?: any): U[];
3553
public move(index: number, newIndex: number);
36-
public pop(): any;
54+
public pop(): T;
3755
public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any;
3856
public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any;
3957
public reverse();
40-
public setAt(index: number, newValue: number);
41-
public shift(): any;
42-
public slice(begin: number, end: number): WinJS.Binding.List;
43-
public some(callback: (val: any, index: number, array: any[]) => boolean, thisArg?: any): boolean;
44-
public sort(sortFunction: (left, right) => number);
45-
public unshift(value: any): number;
58+
public setAt(index: number, newValue: T);
59+
public shift(): T;
60+
public slice(begin: number, end: number): List<T>;
61+
public some(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
62+
public sort(sortFunction: (left: T, right: T) => number);
63+
public filter(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
64+
public unshift(value: T): number;
4665
public length: number;
47-
public notifyMutated(index: number);
48-
66+
public notifyMutated(index: number);
4967
}
5068
class Template {
5169
public element: HTMLElement;
@@ -73,7 +91,7 @@ declare module WinJS {
7391
module Class {
7492
function define(constructor: any, instanceMembers: any): any;
7593
function derive(baseClass: any, constructor: any, instanceMembers: any): any;
76-
function mix(constructor: any, mixin: any): any;
94+
function mix(constructor: any, ...mixin: any[]): any;
7795
}
7896
function xhr(options: { type?: string; url?: string; user?: string; password?: string; headers?: any; data?: any; responseType?: string; }): WinJS.Promise<XMLHttpRequest>;
7997
module Application {
@@ -100,15 +118,21 @@ declare module WinJS {
100118
class ErrorFromName {
101119
constructor(name: string, message?: string);
102120
}
103-
class Promise<T> {
121+
class Promise<T> implements Windows.Foundation.IPromise<T> {
104122
constructor(init: (c: any, e: any, p: any) => void);
105-
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void ): Promise<U>;
106-
then<U>(success?: (value: T) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): Promise<U>;
107-
then<U>(success?: (value: T) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void ): Promise<U>;
108-
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Promise<U>;
123+
then<U>(success?: (value: T) => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
124+
then<U>(success?: (value: T) => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
125+
then<U>(success?: (value: T) => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
126+
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
109127
done<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void;
110-
static join: any;
111-
static timeout: any;
128+
129+
cancel(): void;
130+
131+
static join(values: any[]): Promise<any[]>;
132+
static timeout(timeout: number): Promise<void>;
133+
static as(): Promise<any>;
134+
static as<U>(obj: U): Promise<U>;
135+
static wrapError<U>(obj: U): Promise<U>;
112136
}
113137
module Navigation {
114138
var history: any;
@@ -126,9 +150,23 @@ declare module WinJS {
126150
var onnavigated: CustomEvent;
127151
var onnavigating: CustomEvent;
128152
}
153+
154+
export module Resources {
155+
export var processAll: (element?: HTMLElement) => void;
156+
export var getString: (id: string) => { value: string; empty?: boolean; lang?: string; };
157+
export var addEventListener: (id: string, handler: EventListener, useCapture?: boolean) => void;
158+
}
159+
129160
module Utilities {
130-
function markSupportedForProcessing(obj: any): void;
131-
enum Key {
161+
function markSupportedForProcessing<T>(obj: T): T;
162+
function createEventProperties(...events: string[]): any;
163+
164+
export function addClass(element: HTMLElement, className: string): void;
165+
export function removeClass(element: HTMLElement, className: string): void;
166+
167+
export function hasClass(element: HTMLElement, className: string): boolean;
168+
169+
enum Key {
132170
backspace,
133171
tab,
134172
enter,
@@ -235,9 +273,58 @@ declare module WinJS {
235273
var ListLayout: any;
236274
var GridLayout: any;
237275
var Pages: any;
238-
var Menu: any;
239-
var setOptions: any;
276+
var setOptions: any;
277+
278+
export var Animation: any;
279+
280+
var DOMEventMixin: any;
281+
282+
class Flyout {
283+
constructor(element: HTMLElement, options);
284+
element: Element;
285+
}
286+
287+
module Fragments {
288+
var renderCopy: any;
289+
}
290+
291+
export class HtmlControl {
292+
constructor(element: HTMLElement, options: { uri: string; });
293+
}
294+
295+
interface IItem {
296+
data: any;
297+
}
298+
299+
interface ISelection {
300+
clear(): WinJS.Promise<void>;
301+
count();
302+
getItems(): WinJS.Promise<IItem[]>;
303+
}
304+
305+
class ListView {
306+
element: Element;
307+
elementFromIndex(index: number);
308+
indexOfElement(element: Element);
309+
selection: ISelection;
310+
}
311+
312+
class Menu {
313+
constructor(element: HTMLElement, options);
314+
element: Element;
315+
}
316+
317+
export class MenuCommand {
318+
constructor(element: HTMLElement, options);
319+
}
320+
321+
export class SettingsFlyout {
322+
static populateSettings(e: any): any;
323+
static showSettings(id: string, path: any): any;
324+
}
240325
}
326+
327+
export function xhr(options: { type: string; url: string; }): WinJS.Promise<any>; // user: string; password: string; headers: any; data: any; responseType: string;
241328
}
242329

243330
interface Element {

winrt/winrt.d.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,14 @@ declare module Windows {
496496
close(): void;
497497
}
498498
export interface IAsyncAction extends Windows.Foundation.IAsyncInfo {
499+
then<U>(success?: () => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
500+
then<U>(success?: () => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
501+
then<U>(success?: () => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>;
502+
then<U>(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>;
503+
done? <U>(success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
504+
505+
cancel();
506+
499507
completed: Windows.Foundation.AsyncActionCompletedHandler;
500508
getResults(): void;
501509
}
@@ -521,7 +529,7 @@ declare module Windows {
521529
export interface AsyncActionWithProgressCompletedHandler<TProgress> {
522530
(asyncInfo: Windows.Foundation.IAsyncActionWithProgress<TProgress>, asyncStatus: Windows.Foundation.AsyncStatus): void;
523531
}
524-
export interface IAsyncActionWithProgress<TProgress> extends Windows.Foundation.IAsyncInfo {
532+
export interface IAsyncActionWithProgress<TProgress> extends Windows.Foundation.IAsyncInfo, Windows.Foundation.IPromise<void> {
525533
progress: Windows.Foundation.AsyncActionProgressHandler<TProgress>;
526534
completed: Windows.Foundation.AsyncActionWithProgressCompletedHandler<TProgress>;
527535
getResults(): void;
@@ -3301,11 +3309,11 @@ declare module Windows {
33013309
getResults(): void;
33023310
cancel(): void;
33033311
close(): void;
3304-
then<U>(success: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
3305-
then<U>(success: (value: any) => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
3306-
then<U>(success: (value: any) => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
3307-
then<U>(success: (value: any) => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
3308-
done<U>(success: (value: any) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void;
3312+
then<U>(success?: () => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
3313+
then<U>(success?: () => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
3314+
then<U>(success?: () => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
3315+
then<U>(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
3316+
done<U>(success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void ;
33093317
operation: {
33103318
completed: Windows.Foundation.AsyncOperationCompletedHandler<any>;
33113319
getResults(): any;
@@ -8385,11 +8393,11 @@ declare module Windows {
83858393
getResults(): void;
83868394
cancel(): void;
83878395
close(): void;
8388-
then<U>(success: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
8389-
then<U>(success: (value: any) => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
8390-
then<U>(success: (value: any) => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
8391-
then<U>(success: (value: any) => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
8392-
done<U>(success: (value: any) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void;
8396+
then<U>(success?: () => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
8397+
then<U>(success?: () => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
8398+
then<U>(success?: () => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
8399+
then<U>(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
8400+
done<U>(success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
83938401
operation: {
83948402
completed: Windows.Foundation.AsyncOperationCompletedHandler<any>;
83958403
getResults(): any;
@@ -14635,10 +14643,12 @@ declare module Windows {
1463514643
}
1463614644
declare module Windows.Foundation {
1463714645
export interface IPromise<T> {
14638-
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
14639-
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
14640-
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
14641-
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise<U>;
14642-
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void;
14646+
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): IPromise<U>;
14647+
then<U>(success?: (value: T) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise<U>;
14648+
then<U>(success?: (value: T) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void ): IPromise<U>;
14649+
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise<U>;
14650+
done?<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void;
14651+
14652+
cancel(): void;
1464314653
}
1464414654
}

0 commit comments

Comments
 (0)