From 50ae629d0cf3057dafa0880a7128029513ef686c Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Thu, 1 Feb 2018 00:44:50 +0200 Subject: [PATCH] AngularJS: rename confusing identifiers in tests (#23314) --- types/angular/angular-tests.ts | 324 ++++++++++++++++----------------- 1 file changed, 162 insertions(+), 162 deletions(-) diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 7f5649befb..0b05400f6d 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -289,25 +289,25 @@ foo.then((x) => { // $q signature tests namespace TestQ { - interface TResult { + interface AbcObject { a: number; b: string; c: boolean; } - interface TValue { + interface EfObject { e: number; f: boolean; } - interface TOther { + interface GhObject { g: string; h: number; } - const tResult: TResult = null; - const promiseTResult: angular.IPromise = null; - const tValue: TValue = null; - const promiseTValue: angular.IPromise = null; - const tOther: TOther = null; - const promiseTOther: angular.IPromise = null; + const abcObject: AbcObject = null; + const abcObjectPromise: angular.IPromise = null; + const efObject: EfObject = null; + const efObjectPromise: angular.IPromise = null; + const ghObject: GhObject = null; + const ghObjectPromise: angular.IPromise = null; const $q: angular.IQService = null; const promiseAny: angular.IPromise = null; @@ -316,11 +316,11 @@ namespace TestQ { // $q constructor { - let result: angular.IPromise; - result = new $q((resolve: (value: TResult) => any) => {}); - result = new $q((resolve: (value: TResult) => any, reject: (value: any) => any) => {}); - result = $q((resolve: (value: TResult) => any) => {}); - result = $q((resolve: (value: TResult) => any, reject: (value: any) => any) => {}); + let result: angular.IPromise; + result = new $q((resolve: (value: AbcObject) => any) => {}); + result = new $q((resolve: (value: AbcObject) => any, reject: (value: any) => any) => {}); + result = $q((resolve: (value: AbcObject) => any) => {}); + result = $q((resolve: (value: AbcObject) => any, reject: (value: any) => any) => {}); } // $q.all @@ -332,8 +332,8 @@ namespace TestQ { $q.all([1, $q.when(2), '3']).then(([ n1, n2, n3 ]) => n1.toFixed() + n2.toFixed() + n3.slice(1)); } { - let result: angular.IPromise; - result = $q.all([promiseAny, promiseAny]); + let result: angular.IPromise; + result = $q.all([promiseAny, promiseAny]); } { let result: angular.IPromise<{[id: string]: any; }>; @@ -356,13 +356,13 @@ namespace TestQ { // $q.defer { - let result: angular.IDeferred; - result = $q.defer(); - result.resolve(tResult); + let result: angular.IDeferred; + result = $q.defer(); + result.resolve(abcObject); const anyValue: any = null; result.reject(anyValue); result.promise.then(result => { - return $q.resolve(result); + return $q.resolve(result); }); } @@ -380,10 +380,10 @@ namespace TestQ { result = $q.resolve(); } { - let result: angular.IPromise; - result = $q.resolve(tResult); - result = $q.resolve(promiseTResult); - const result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther); + let result: angular.IPromise; + result = $q.resolve(abcObject); + result = $q.resolve(abcObjectPromise); + const result2: angular.IPromise = $q.resolve(Math.random() > 0.5 ? abcObject : ghObjectPromise); } // $q.when @@ -392,32 +392,32 @@ namespace TestQ { result = $q.when(); } { - let result: angular.IPromise; - let resultOther: angular.IPromise; + let result: angular.IPromise; + let resultOther: angular.IPromise; - result = $q.when(tResult); - result = $q.when(promiseTResult); + result = $q.when(abcObject); + result = $q.when(abcObjectPromise); - result = $q.when(tValue, (result: TValue) => tResult); - result = $q.when(tValue, (result: TValue) => tResult, (any) => any); - result = $q.when(tValue, (result: TValue) => tResult, (any) => any, (any) => any); + result = $q.when(efObject, (result: EfObject) => abcObject); + result = $q.when(efObject, (result: EfObject) => abcObject, (any) => any); + result = $q.when(efObject, (result: EfObject) => abcObject, (any) => any, (any) => any); - result = $q.when(promiseTValue, (result: TValue) => tResult); - resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); - resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther); - resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any); - resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther); - resultOther = $q.when(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any); + result = $q.when(efObjectPromise, (result: EfObject) => abcObject); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObject, (any) => any); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObjectPromise); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObject, (any) => ghObjectPromise, (any) => any); - result = $q.when(tValue, (result: TValue) => promiseTResult); - result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any); - result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any); + result = $q.when(efObject, (result: EfObject) => abcObjectPromise); + result = $q.when(efObject, (result: EfObject) => abcObjectPromise, (any) => any); + result = $q.when(efObject, (result: EfObject) => abcObjectPromise, (any) => any, (any) => any); - result = $q.when(promiseTValue, (result: TValue) => promiseTResult); - resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther); - resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any); - resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther); - resultOther = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any); + result = $q.when(efObjectPromise, (result: EfObject) => abcObjectPromise); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObject); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObject, (any) => any); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObjectPromise); + resultOther = $q.when(efObjectPromise, (result: EfObject) => abcObjectPromise, (any) => ghObjectPromise, (any) => any); } } @@ -440,41 +440,41 @@ httpFoo.then((response: ng.IHttpResponse) => { // Deferred signature tests namespace TestDeferred { - const any: any = null; + const anything: any = null; - interface TResult { + interface AbcObject { a: number; b: string; c: boolean; } - const tResult: TResult = null; + const abcObject: AbcObject = null; - const deferred: angular.IDeferred = null; + const deferred: angular.IDeferred = null; // deferred.resolve { let result: void; result = deferred.resolve(); - result = deferred.resolve(tResult); + result = deferred.resolve(abcObject); } // deferred.reject { let result: void; result = deferred.reject(); - result = deferred.reject(any); + result = deferred.reject(anything); } // deferred.notify { let result: void; result = deferred.notify(); - result = deferred.notify(any); + result = deferred.notify(anything); } // deferred.promise { - let result: angular.IPromise; + let result: angular.IPromise; result = deferred.promise; } } @@ -517,139 +517,139 @@ namespace TestInjector { // Promise signature tests namespace TestPromise { - const any: any = null; + const anything: any = null; - interface TResult { - kind: 'result'; + interface AbcObject { + kind: 'abc'; a: number; b: string; c: boolean; } - interface TOther { - kind: 'other'; + interface DefObject { + kind: 'def'; d: number; e: string; f: boolean; } - function isTResult(x: TResult | TOther): x is TResult { - return x.kind === 'result'; + function isAbcObject(x: AbcObject | DefObject): x is AbcObject { + return x.kind === 'abc'; } - const tresult: TResult = null; - const tresultPromise: ng.IPromise = null; - const tresultHttpPromise: ng.IHttpPromise = null; + const abcObject: AbcObject = null; + const abcObjectPromise: ng.IPromise = null; + const abcObjectHttpPromise: ng.IHttpPromise = null; - const tother: TOther = null; - const totherPromise: ng.IPromise = null; - const totherHttpPromise: ng.IHttpPromise = null; + const defObject: DefObject = null; + const defObjectPromise: ng.IPromise = null; + const defObjectHttpPromise: ng.IHttpPromise = null; - const promise: angular.IPromise = null; + const promise: angular.IPromise = null; const $q: angular.IQService = null; - const reject = $q.reject(); + const rejectedPromise = $q.reject(); // promise.then // $ExpectType IPromise - promise.then(result => any); + promise.then(result => anything); // $ExpectType IPromise - promise.then(result => any, any => any); + promise.then(result => anything, any => any); // $ExpectType IPromise - promise.then(result => any, any => any, any => any); + promise.then(result => anything, any => any, any => any); // $ExpectType IPromise - promise.then(result => reject); + promise.then(result => rejectedPromise); // $ExpectType IPromise - promise.then(result => reject, any => reject); + promise.then(result => rejectedPromise, any => rejectedPromise); // $ExpectType IPromise - promise.then(result => reject, any => reject, any => any); + promise.then(result => rejectedPromise, any => rejectedPromise, any => any); - // $ExpectType IPromise + // $ExpectType IPromise promise.then(result => result); - // $ExpectType IPromise - promise.then(result => tresult); - // $ExpectType IPromise - promise.then(result => tresultPromise); + // $ExpectType IPromise + promise.then(result => abcObject); + // $ExpectType IPromise + promise.then(result => abcObjectPromise); // $ExpectType IPromise promise.then(result => result, any => any); - // $ExpectType IPromise + // $ExpectType IPromise promise.then(result => result, any => Math.random()); // $ExpectType IPromise promise.then(result => result, any => any, any => any); - // $ExpectType IPromise + // $ExpectType IPromise promise.then(result => result, any => Math.random(), any => any); - // $ExpectType IPromise - promise.then(result => result, any => reject, any => any); + // $ExpectType IPromise + promise.then(result => result, any => rejectedPromise, any => any); - // $ExpectType IPromise - promise.then(result => anyOf2(reject, result)); - // $ExpectType IPromise - promise.then(result => anyOf3(result, tresultPromise, reject)); - // $ExpectType IPromise + // $ExpectType IPromise + promise.then(result => anyOf2(rejectedPromise, result)); + // $ExpectType IPromise + promise.then(result => anyOf3(result, abcObjectPromise, rejectedPromise)); + // $ExpectType IPromise promise.then( - result => anyOf3(reject, result, tresultPromise), - reason => anyOf3(reject, tresult, tresultPromise) + result => anyOf3(rejectedPromise, result, abcObjectPromise), + reason => anyOf3(rejectedPromise, abcObject, abcObjectPromise) ); - // $ExpectType IPromise> - promise.then(result => tresultHttpPromise); + // $ExpectType IPromise> + promise.then(result => abcObjectHttpPromise); - // $ExpectType IPromise - promise.then(result => result, any => tother); + // $ExpectType IPromise + promise.then(result => result, any => defObject); // These are broken and seemingly can't be made to work // with the current limitations of TypeScript. - // xExpectType IPromise - // promise.then(result => anyOf2(result, totherPromise)); - // xExpectType IPromise - // promise.then(result => anyOf3(reject, result, totherPromise)); - // xExpectType IPromise + // xExpectType IPromise + // promise.then(result => anyOf2(result, defObjectPromise)); + // xExpectType IPromise + // promise.then(result => anyOf3(rejectedPromise, result, defObjectPromise)); + // xExpectType IPromise // const a4 = promise.then( - // result => anyOf3(reject, result, totherPromise), - // reason => anyOf3(reject, tother, tresultPromise) + // result => anyOf3(rejectedPromise, result, defObjectPromise), + // reason => anyOf3(rejectedPromise, defObject, abcObjectPromise) // ); - // $ExpectType IPromise - promise.then(result => - anyOf3(tresultPromise, result, totherPromise) + // $ExpectType IPromise + promise.then(result => + anyOf3(abcObjectPromise, result, defObjectPromise) ); - // $ExpectType IPromise - promise.then(result => result, any => tother, any => any); - // $ExpectType IPromise - promise.then(result => tresultPromise, any => totherPromise); - // $ExpectType IPromise - promise.then(result => tresultPromise, any => totherPromise, any => any); - // $ExpectType IPromise | IHttpResponse> - promise.then(result => tresultHttpPromise, any => totherHttpPromise); - // $ExpectType IPromise | IHttpResponse> - promise.then(result => tresultHttpPromise, any => totherHttpPromise, any => any); + // $ExpectType IPromise + promise.then(result => result, any => defObject, any => any); + // $ExpectType IPromise + promise.then(result => abcObjectPromise, any => defObjectPromise); + // $ExpectType IPromise + promise.then(result => abcObjectPromise, any => defObjectPromise, any => any); + // $ExpectType IPromise | IHttpResponse> + promise.then(result => abcObjectHttpPromise, any => defObjectHttpPromise); + // $ExpectType IPromise | IHttpResponse> + promise.then(result => abcObjectHttpPromise, any => defObjectHttpPromise, any => any); - // $ExpectType IPromise - promise.then(result => tother); + // $ExpectType IPromise + promise.then(result => defObject); // $ExpectType IPromise - promise.then(result => tother, any => any); + promise.then(result => defObject, any => any); // $ExpectType IPromise - promise.then(result => tother, any => any, any => any); - // $ExpectType IPromise - promise.then(result => totherPromise); + promise.then(result => defObject, any => any, any => any); + // $ExpectType IPromise + promise.then(result => defObjectPromise); // $ExpectType IPromise - promise.then(result => totherPromise, any => any); + promise.then(result => defObjectPromise, any => any); // $ExpectType IPromise - promise.then(result => totherPromise, any => any, any => any); - // $ExpectType IPromise> - promise.then(result => totherHttpPromise); + promise.then(result => defObjectPromise, any => any, any => any); + // $ExpectType IPromise> + promise.then(result => defObjectHttpPromise); // $ExpectType IPromise - promise.then(result => totherHttpPromise, any => any); + promise.then(result => defObjectHttpPromise, any => any); // $ExpectType IPromise - promise.then(result => totherHttpPromise, any => any, any => any); + promise.then(result => defObjectHttpPromise, any => any, any => any); // $ExpectType IPromise promise - .then(result => tresult, any => tother) - .then(ambiguous => (isTResult(ambiguous) ? ambiguous.c : ambiguous.f)); + .then(result => abcObject, any => defObject) + .then(ambiguous => (isAbcObject(ambiguous) ? ambiguous.c : ambiguous.f)); // promise.then + $q.reject: @@ -668,38 +668,38 @@ namespace TestPromise { // $ExpectType IPromise promise.catch(err => err); // $ExpectType IPromise - promise.catch(err => any); - // $ExpectType IPromise - promise.catch(err => tresult); - // $ExpectType IPromise - promise.catch(err => anyOf2(tresult, reject)); - // $ExpectType IPromise - promise.catch(err => anyOf3(tresult, tresultPromise, reject)); - // $ExpectType IPromise - promise.catch(err => tresultPromise); - // $ExpectType IPromise> - promise.catch(err => tresultHttpPromise); - // $ExpectType IPromise - promise.catch(err => tother); - // $ExpectType IPromise - promise.catch(err => totherPromise); - // $ExpectType IPromise> - promise.catch(err => totherHttpPromise); + promise.catch(err => anything); + // $ExpectType IPromise + promise.catch(err => abcObject); + // $ExpectType IPromise + promise.catch(err => anyOf2(abcObject, rejectedPromise)); + // $ExpectType IPromise + promise.catch(err => anyOf3(abcObject, abcObjectPromise, rejectedPromise)); + // $ExpectType IPromise + promise.catch(err => abcObjectPromise); + // $ExpectType IPromise> + promise.catch(err => abcObjectHttpPromise); + // $ExpectType IPromise + promise.catch(err => defObject); + // $ExpectType IPromise + promise.catch(err => defObjectPromise); + // $ExpectType IPromise> + promise.catch(err => defObjectHttpPromise); // $ExpectType IPromise promise - .catch(err => tother) + .catch(err => defObject) .then( - ambiguous => (isTResult(ambiguous) ? ambiguous.c : ambiguous.f) + ambiguous => (isAbcObject(ambiguous) ? ambiguous.c : ambiguous.f) ); // promise.finally - // $ExpectType IPromise - promise.finally(() => any); - // $ExpectType IPromise - promise.finally(() => tresult); - // $ExpectType IPromise - promise.finally(() => tother); + // $ExpectType IPromise + promise.finally(() => anything); + // $ExpectType IPromise + promise.finally(() => abcObject); + // $ExpectType IPromise + promise.finally(() => defObject); } function test_angular_forEach() { @@ -726,12 +726,12 @@ let elementReadyFn = angular.element(() => { // $timeout signature tests namespace TestTimeout { - interface TResult { + interface AbcObject { a: number; b: string; c: boolean; } - const fnTResult: (...args: any[]) => TResult = null; + const abcObjectFn: (...args: any[]) => AbcObject = null; const promiseAny: angular.IPromise = null; const $timeout: angular.ITimeoutService = null; @@ -746,13 +746,13 @@ namespace TestTimeout { 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); + let result: angular.IPromise; + result = $timeout(abcObjectFn); + result = $timeout(abcObjectFn, 1); + result = $timeout(abcObjectFn, 1, true); + result = $timeout(abcObjectFn, 1, true, 1); + result = $timeout(abcObjectFn, 1, true, 1, ''); + result = $timeout(abcObjectFn, 1, true, 1, '', true); } // $timeout.cancel