From 406a22a9c1ed920e23f0b4ad6069810962479885 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 30 Jul 2016 03:49:59 +0530 Subject: [PATCH] Implemented a simpler then interface as generic typings was not needed --- hellojs/hellojs.d.ts | 59 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 7dabae4054..d54bca2905 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -27,57 +27,24 @@ interface HelloJSEvent { success(callback: (json?: any) => void): HelloJSStatic; error(callback: (json?: any) => void): HelloJSStatic; complete(callback: (json?: any) => void): HelloJSStatic; + then(successCallback: (json?: any) => void, errorCallback: (json?: any) => void): HelloJSStatic; } +interface HelloJSThenable { + then(successCallback: (json?: any) => void, errorCallback: (json?: any) => void): HelloJSStatic; +} + + interface HelloJSEventArgument { network: string; authResponse?: any; } -interface HelloJSImmediateSuccessCB { - (value: T): TP; -} - -interface HelloJSImmediateErrorCB { - (err: any): TP; -} - -interface HelloJSDeferredSuccessCB { - (value: T): HelloJSThenable; -} - -interface HelloJSDeferredErrorCB { - (error: any): HelloJSThenable; -} - -interface HelloJSThenable { - then( - successCB?: HelloJSDeferredSuccessCB, - errorCB?: HelloJSDeferredErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSDeferredSuccessCB, - errorCB?: HelloJSImmediateErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSImmediateSuccessCB, - errorCB?: HelloJSDeferredErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSImmediateSuccessCB, - errorCB?: HelloJSImmediateErrorCB - ): HelloJSThenable; -} - - interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -85,15 +52,11 @@ interface HelloJSStatic extends HelloJSEvent { init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; } - - - - interface HelloJSStaticNamed { - login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(callback?: () => void): HelloJSThenable; + login(option?: HelloJSLoginOptions, callback?: () => void): void; + logout(callback?: () => void): void; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic; } interface HelloJSOAuthDef {