diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index cba248b44..99a5e33c2 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -13,39 +13,59 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +/// + declare module WinJS { function strictProcessing(): void; + + export module Application { + export var onsettings: EventListener; + } + module Binding { function as(data: any): any; - class List { - constructor(data?: any[]); - public push(item: any): any; - public indexOf(item: any): number; - public splice(start: number, howMany?: number, item?: any[]): any[]; - public createFiltered(predicate: (x: any) => boolean): List; - public createGrouped(keySelector: (x: any) => any, dataSelector: (x:any) => any, groupSorter: (left:any, right:any) => number): List; - public groups: any; + function processAll(rootElement?: any, dataContext?: any, skipRoot?: boolean, bindingCache?: any): any; + function define(data: any): any; + function expandProperties(data: any): any; + function converter(method: any): any; + + export var optimizeBindingReferences: boolean; + export var mixin: any; + export var bind: any; + export var oneTime: any; + + export function initializer(customInit: any): any; + export var setAttribute: any; + + class List { + constructor(data?: T[], options?: { binding: boolean; proxy: boolean; }); + public push(item: T): number; + public indexOf(item: T, fromIndex?: number): number; + public splice(start: number, howMany?: number, ...items: T[]): T[]; + public createFiltered(predicate: (x: T) => boolean): List; + public createGrouped(keySelector: (x: T) => string, dataSelector: (x:T) => U, groupSorter?: (left:string, right:string) => number): List; + public createSorted(sorter: (left:T, right:T) => number): List; + public groups: List; public dataSource: any; - public getAt(index: number): any; - public createSorted(sorter: (left, right) => number); - public forEach(callback: (val: any, index: number, array: any[]) => void, thisArg?: any); - public every(callback: (val: any, index: number, array: any[]) => boolean, thisArg?: any): boolean; + public getAt(index: number): T; + public forEach(callback: (val: T, index: number, array: T[]) => void, thisArg?: any): void; + public every(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; public join(separator: string): string; - public map(callback: (val: any, index: number, array: any[]) => any, thisArg?: any): any[]; - public move(index: number, newIndex: number); - public pop(): any; + public map(callback: (val: T, index: number, array: T[]) => U, thisArg?: any): U[]; + public move(index: number, newIndex: number): void; + public pop(): T; public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue?: any): any; - public reverse(); - public setAt(index: number, newValue: number); - public shift(): any; - public slice(begin: number, end: number): WinJS.Binding.List; - public some(callback: (val: any, index: number, array: any[]) => boolean, thisArg?: any): boolean; - public sort(sortFunction: (left, right) => number); - public unshift(value: any): number; + public reverse(): void; + public setAt(index: number, newValue: T): void; + public shift(): T; + public slice(begin: number, end: number): List; + public some(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + public sort(sortFunction: (left: T, right: T) => number): void; + public filter(callback: (val: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + public unshift(value: T): number; public length: number; - public notifyMutated(index: number); - + public notifyMutated(index: number): void; } class Template { public element: HTMLElement; @@ -61,7 +81,7 @@ declare module WinJS { (dataContext: any, container?: HTMLElement): WinJS.Promise; value(href: string, dataContext: any, container?: HTMLElement): WinJS.Promise; }; - public renderItem(item: any, recycled?: HTMLElement); + public renderItem(item: any, recycled?: HTMLElement): void; } @@ -73,7 +93,7 @@ declare module WinJS { module Class { function define(constructor: any, instanceMembers: any): any; function derive(baseClass: any, constructor: any, instanceMembers: any): any; - function mix(constructor: any, mixin: any): any; + function mix(constructor: any, ...mixin: any[]): any; } function xhr(options: { type?: string; url?: string; user?: string; password?: string; headers?: any; data?: any; responseType?: string; }): WinJS.Promise; module Application { @@ -100,15 +120,21 @@ declare module WinJS { class ErrorFromName { constructor(name: string, message?: string); } - class Promise { + class Promise implements Windows.Foundation.IPromise { constructor(init: (c: any, e: any, p: any) => void); - then(success?: (value: T) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void ): Promise; - then(success?: (value: T) => Promise, error?: (error: any) => U, progress?: (progress: any) => void ): Promise; - then(success?: (value: T) => U, error?: (error: any) => Promise, progress?: (progress: any) => void ): Promise; - then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Promise; + then(success?: (value: T) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: (value: T) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: (value: T) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; done(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; - static join: any; - static timeout: any; + + cancel(): void; + + static join(values: any[]): Promise; + static timeout(timeout: number): Promise; + static as(): Promise; + static as(obj: U): Promise; + static wrapError(obj: U): Promise; } module Navigation { var history: any; @@ -119,16 +145,30 @@ declare module WinJS { function addEventListener(type: string, listener: EventListener, capture: boolean): void; function back(): void; function forward(): void; - function navigate(location: any, initialState: any); - function navigate(location: any); + function navigate(location: any, initialState: any): WinJS.Promise; + function navigate(location: any): WinJS.Promise; function removeEventListener(type: string, listener: EventListener, capture: boolean): void; var onbeforenavigate: CustomEvent; var onnavigated: CustomEvent; var onnavigating: CustomEvent; } + + export module Resources { + export var processAll: (element?: HTMLElement) => void; + export var getString: (id: string) => { value: string; empty?: boolean; lang?: string; }; + export var addEventListener: (id: string, handler: EventListener, useCapture?: boolean) => void; + } + module Utilities { - function markSupportedForProcessing(obj: any): void; - enum Key { + function markSupportedForProcessing(obj: T): T; + function createEventProperties(...events: string[]): any; + + export function addClass(element: HTMLElement, className: string): void; + export function removeClass(element: HTMLElement, className: string): void; + + export function hasClass(element: HTMLElement, className: string): boolean; + + enum Key { backspace, tab, enter, @@ -235,9 +275,58 @@ declare module WinJS { var ListLayout: any; var GridLayout: any; var Pages: any; - var Menu: any; - var setOptions: any; + var setOptions: any; + + export var Animation: any; + + var DOMEventMixin: any; + + class Flyout { + constructor(element: HTMLElement, options: any); + element: Element; + } + + module Fragments { + var renderCopy: any; + } + + export class HtmlControl { + constructor(element: HTMLElement, options: { uri: string; }); + } + + interface IItem { + data: any; + } + + interface ISelection { + clear(): WinJS.Promise; + count(): number; + getItems(): WinJS.Promise; + } + + class ListView { + element: Element; + elementFromIndex(index: number): Element; + indexOfElement(element: Element): number; + selection: ISelection; + } + + class Menu { + constructor(element: HTMLElement, options: any); + element: Element; + } + + export class MenuCommand { + constructor(element: HTMLElement, options: any); + } + + export class SettingsFlyout { + static populateSettings(e: any): any; + static showSettings(id: string, path: any): any; + } } + + export function xhr(options: { type: string; url: string; }): WinJS.Promise; // user: string; password: string; headers: any; data: any; responseType: string; } interface Element { diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 11f1dba86..881b64ed3 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -496,6 +496,14 @@ declare module Windows { close(): void; } export interface IAsyncAction extends Windows.Foundation.IAsyncInfo { + then(success?: () => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; + then(success?: () => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; + then(success?: () => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; + then(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; + done? (success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + + cancel(): void; + completed: Windows.Foundation.AsyncActionCompletedHandler; getResults(): void; } @@ -521,7 +529,7 @@ declare module Windows { export interface AsyncActionWithProgressCompletedHandler { (asyncInfo: Windows.Foundation.IAsyncActionWithProgress, asyncStatus: Windows.Foundation.AsyncStatus): void; } - export interface IAsyncActionWithProgress extends Windows.Foundation.IAsyncInfo { + export interface IAsyncActionWithProgress extends Windows.Foundation.IAsyncInfo, Windows.Foundation.IPromise { progress: Windows.Foundation.AsyncActionProgressHandler; completed: Windows.Foundation.AsyncActionWithProgressCompletedHandler; getResults(): void; @@ -3301,11 +3309,11 @@ declare module Windows { getResults(): void; cancel(): void; close(): void; - then(success: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - done(success: (value: any) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; + then(success?: () => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; + done(success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void ; operation: { completed: Windows.Foundation.AsyncOperationCompletedHandler; getResults(): any; @@ -8385,11 +8393,11 @@ declare module Windows { getResults(): void; cancel(): void; close(): void; - then(success: (value: any) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success: (value: any) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - done(success: (value: any) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; + then(success?: () => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; + then(success?: () => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; + done(success?: () => any, error?: (error: any) => any, progress?: (progress: any) => void): void; operation: { completed: Windows.Foundation.AsyncOperationCompletedHandler; getResults(): any; @@ -14635,10 +14643,12 @@ declare module Windows { } declare module Windows.Foundation { export interface IPromise { - then(success?: (value: T) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): Windows.Foundation.IPromise; - done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void ): void; + then(success?: (value: T) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void ): IPromise; + then(success?: (value: T) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise; + then(success?: (value: T) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void ): IPromise; + then(success?: (value: T) => U, error?: (error: any) => U, progress?: (progress: any) => void ): IPromise; + done?(success?: (value: T) => any, error?: (error: any) => any, progress?: (progress: any) => void): void; + + cancel(): void; } }