From e4b22c838ce69c66e650d36a3132c9639dbf58aa Mon Sep 17 00:00:00 2001 From: Joel Mueller Date: Sat, 24 Jan 2015 18:17:38 -0600 Subject: [PATCH] Added generics to promise/defer. Allowing for better type-safety. --- mithril/mithril.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mithril/mithril.d.ts b/mithril/mithril.d.ts index d106025ba..525ded3aa 100644 --- a/mithril/mithril.d.ts +++ b/mithril/mithril.d.ts @@ -20,9 +20,9 @@ interface MithrilStatic { route(path: string, params?: any, shouldReplaceHistory?: boolean): void; route(): string; route(element: Element, isInitialized: boolean): void; - request(options: MithrilXHROptions): MithrilPromise; - deferred(): MithrilDeferred; - sync(promises: MithrilPromise[]): MithrilPromise; + request(options: MithrilXHROptions): MithrilPromise; + deferred(): MithrilDeferred; + sync(promises: MithrilPromise[]): MithrilPromise; startComputation(): void; endComputation(): void; } @@ -43,15 +43,15 @@ interface MithrilModule { view: Function; } -interface MithrilDeferred { - resolve(value?: any): void; - reject(value?: any): void; - promise: MithrilPromise; +interface MithrilDeferred { + resolve(value?: T): void; + reject(value?: any): void; + promise: MithrilPromise; } -interface MithrilPromise { - (value?: any): any; - then(successCallback?: (value: any) => any, errorCallback?: (value: any) => any): MithrilPromise; +interface MithrilPromise { + (value?: T): T; + then(successCallback?: (value: T) => R, errorCallback?: (value: any) => any): MithrilPromise; } interface MithrilXHROptions {