Skip to content

Commit 71207a1

Browse files
committed
Merge pull request DefinitelyTyped#1503 from OliveTreeBible/master
Work to extend the definitions for WinJS and WinRT
2 parents dbbfae9 + 1f2d03f commit 71207a1

File tree

2 files changed

+154
-55
lines changed

2 files changed

+154
-55
lines changed

winjs/winjs.d.ts

Lines changed: 128 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,59 @@ See the Apache Version 2.0 License for specific language governing permissions
1313
and limitations under the License.
1414
***************************************************************************** */
1515

16+
///<reference path="../winrt/winrt.d.ts"/>
17+
1618
declare module WinJS {
1719
function strictProcessing(): void;
20+
21+
export module Application {
22+
export var onsettings: EventListener;
23+
}
24+
1825
module Binding {
1926
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;
27+
function processAll(rootElement?: any, dataContext?: any, skipRoot?: boolean, bindingCache?: any): any;
28+
function define(data: any): any;
29+
function expandProperties(data: any): any;
30+
function converter(method: any): any;
31+
32+
export var optimizeBindingReferences: boolean;
33+
export var mixin: any;
34+
export var bind: any;
35+
export var oneTime: any;
36+
37+
export function initializer(customInit: any): any;
38+
export var setAttribute: any;
39+
40+
class List<T> {
41+
constructor(data?: T[], options?: { binding: boolean; proxy: boolean; });
42+
public push(item: T): number;
43+
public indexOf(item: T, fromIndex?: number): number;
44+
public splice(start: number, howMany?: number, ...items: T[]): T[];
45+
public createFiltered(predicate: (x: T) => boolean): List<T>;
46+
public createGrouped<U>(keySelector: (x: T) => string, dataSelector: (x:T) => U, groupSorter?: (left:string, right:string) => number): List<T>;
47+
public createSorted(sorter: (left:T, right:T) => number): List<T>;
48+
public groups: List<any>;
2849
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;
50+
public getAt(index: number): T;
51+
public forEach(callback: (val: T, index: number, array: T[]) => void, thisArg?: any): void;
52+
public every(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
3353
public join(separator: string): string;
34-
public map(callback: (val: any, index: number, array: any[]) => any, thisArg?: any): any[];
35-
public move(index: number, newIndex: number);
36-
public pop(): any;
54+
public map<U>(callback: (val: T, index: number, array: T[]) => U, thisArg?: any): U[];
55+
public move(index: number, newIndex: number): void;
56+
public pop(): T;
3757
public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any;
3858
public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any;
39-
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;
59+
public reverse(): void;
60+
public setAt(index: number, newValue: T): void;
61+
public shift(): T;
62+
public slice(begin: number, end: number): List<T>;
63+
public some(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
64+
public sort(sortFunction: (left: T, right: T) => number): void;
65+
public filter(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
66+
public unshift(value: T): number;
4667
public length: number;
47-
public notifyMutated(index: number);
48-
68+
public notifyMutated(index: number): void;
4969
}
5070
class Template {
5171
public element: HTMLElement;
@@ -61,7 +81,7 @@ declare module WinJS {
6181
(dataContext: any, container?: HTMLElement): WinJS.Promise<HTMLElement>;
6282
value(href: string, dataContext: any, container?: HTMLElement): WinJS.Promise<HTMLElement>;
6383
};
64-
public renderItem(item: any, recycled?: HTMLElement);
84+
public renderItem(item: any, recycled?: HTMLElement): void;
6585
}
6686

6787

@@ -73,7 +93,7 @@ declare module WinJS {
7393
module Class {
7494
function define(constructor: any, instanceMembers: any): any;
7595
function derive(baseClass: any, constructor: any, instanceMembers: any): any;
76-
function mix(constructor: any, mixin: any): any;
96+
function mix(constructor: any, ...mixin: any[]): any;
7797
}
7898
function xhr(options: { type?: string; url?: string; user?: string; password?: string; headers?: any; data?: any; responseType?: string; }): WinJS.Promise<XMLHttpRequest>;
7999
module Application {
@@ -100,15 +120,21 @@ declare module WinJS {
100120
class ErrorFromName {
101121
constructor(name: string, message?: string);
102122
}
103-
class Promise<T> {
123+
class Promise<T> implements Windows.Foundation.IPromise<T> {
104124
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>;
125+
then<U>(success?: (value: T) => Windows.Foundation.IPromise<U>, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
126+
then<U>(success?: (value: T) => Windows.Foundation.IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
127+
then<U>(success?: (value: T) => U, error?: (error: any) => Windows.Foundation.IPromise<U>, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
128+
then<U>(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise<U>;
109129
done<U>(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void;
110-
static join: any;
111-
static timeout: any;
130+
131+
cancel(): void;
132+
133+
static join(values: any[]): Promise<any[]>;
134+
static timeout(timeout: number): Promise<void>;
135+
static as(): Promise<any>;
136+
static as<U>(obj: U): Promise<U>;
137+
static wrapError<U>(obj: U): Promise<U>;
112138
}
113139
module Navigation {
114140
var history: any;
@@ -119,16 +145,30 @@ declare module WinJS {
119145
function addEventListener(type: string, listener: EventListener, capture: boolean): void;
120146
function back(): void;
121147
function forward(): void;
122-
function navigate(location: any, initialState: any);
123-
function navigate(location: any);
148+
function navigate(location: any, initialState: any): WinJS.Promise<boolean>;
149+
function navigate(location: any): WinJS.Promise<boolean>;
124150
function removeEventListener(type: string, listener: EventListener, capture: boolean): void;
125151
var onbeforenavigate: CustomEvent;
126152
var onnavigated: CustomEvent;
127153
var onnavigating: CustomEvent;
128154
}
155+
156+
export module Resources {
157+
export var processAll: (element?: HTMLElement) => void;
158+
export var getString: (id: string) => { value: string; empty?: boolean; lang?: string; };
159+
export var addEventListener: (id: string, handler: EventListener, useCapture?: boolean) => void;
160+
}
161+
129162
module Utilities {
130-
function markSupportedForProcessing(obj: any): void;
131-
enum Key {
163+
function markSupportedForProcessing<T>(obj: T): T;
164+
function createEventProperties(...events: string[]): any;
165+
166+
export function addClass(element: HTMLElement, className: string): void;
167+
export function removeClass(element: HTMLElement, className: string): void;
168+
169+
export function hasClass(element: HTMLElement, className: string): boolean;
170+
171+
enum Key {
132172
backspace,
133173
tab,
134174
enter,
@@ -235,9 +275,58 @@ declare module WinJS {
235275
var ListLayout: any;
236276
var GridLayout: any;
237277
var Pages: any;
238-
var Menu: any;
239-
var setOptions: any;
278+
var setOptions: any;
279+
280+
export var Animation: any;
281+
282+
var DOMEventMixin: any;
283+
284+
class Flyout {
285+
constructor(element: HTMLElement, options: any);
286+
element: Element;
287+
}
288+
289+
module Fragments {
290+
var renderCopy: any;
291+
}
292+
293+
export class HtmlControl {
294+
constructor(element: HTMLElement, options: { uri: string; });
295+
}
296+
297+
interface IItem {
298+
data: any;
299+
}
300+
301+
interface ISelection {
302+
clear(): WinJS.Promise<void>;
303+
count(): number;
304+
getItems(): WinJS.Promise<IItem[]>;
305+
}
306+
307+
class ListView {
308+
element: Element;
309+
elementFromIndex(index: number): Element;
310+
indexOfElement(element: Element): number;
311+
selection: ISelection;
312+
}
313+
314+
class Menu {
315+
constructor(element: HTMLElement, options: any);
316+
element: Element;
317+
}
318+
319+
export class MenuCommand {
320+
constructor(element: HTMLElement, options: any);
321+
}
322+
323+
export class SettingsFlyout {
324+
static populateSettings(e: any): any;
325+
static showSettings(id: string, path: any): any;
326+
}
240327
}
328+
329+
export function xhr(options: { type: string; url: string; }): WinJS.Promise<any>; // user: string; password: string; headers: any; data: any; responseType: string;
241330
}
242331

243332
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(): void;
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)