From 7652914a5b38b44434f1f4173f377a05cb8f2cfd Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 11 Aug 2015 21:51:19 +0500 Subject: [PATCH] angularjs: changed $timeout signature, added tests --- angularjs/angular-tests.ts | 39 ++++++++++++++++++++++++++++++++++++++ angularjs/angular.d.ts | 5 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 10d806217..a9f77b97e 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -381,6 +381,45 @@ var scope: ng.IScope = element.scope(); var isolateScope: ng.IScope = element.isolateScope(); +// $timeout signature tests +module TestTimeout { + interface TResult { + a: number; + b: string; + c: boolean; + } + var fnTResult: (...args: any[]) => TResult; + var promiseAny: angular.IPromise; + var $timeout: angular.ITimeoutService; + + // $timeout + { + let result: angular.IPromise; + result = $timeout(); + } + { + let result: angular.IPromise; + result = $timeout(1); + result = $timeout(1, true); + } + { + let result: angular.IPromise; + result = $timeout(fnTResult); + result = $timeout(fnTResult, 1); + result = $timeout(fnTResult, 1, true); + result = $timeout(fnTResult, 1, true, 1); + result = $timeout(fnTResult, 1, true, 1, ''); + result = $timeout(fnTResult, 1, true, 1, '', true); + } + + // $timeout.cancel + { + let result: boolean; + result = $timeout.cancel(); + result = $timeout.cancel(promiseAny); + } +} + function test_IAttributes(attributes: ng.IAttributes){ return attributes; diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 17c0c9384..0dc9ca2ca 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -725,8 +725,9 @@ declare module angular { // see http://docs.angularjs.org/api/ng.$timeout /////////////////////////////////////////////////////////////////////////// interface ITimeoutService { - (func: (...args: any[]) => T, delay?: number, invokeApply?: boolean): IPromise; - cancel(promise: IPromise): boolean; + (delay?: number, invokeApply?: boolean): IPromise; + (fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise; + cancel(promise?: IPromise): boolean; } ///////////////////////////////////////////////////////////////////////////