diff --git a/goldens/public-api/core/index.md b/goldens/public-api/core/index.md index 93b8d269daf..c521c1145ba 100644 --- a/goldens/public-api/core/index.md +++ b/goldens/public-api/core/index.md @@ -1524,7 +1524,7 @@ export enum ViewEncapsulation { export abstract class ViewRef extends ChangeDetectorRef { abstract destroy(): void; abstract get destroyed(): boolean; - abstract onDestroy(callback: Function): any /** TODO #9100 */; + abstract onDestroy(callback: Function): any /** TODO #9100, replace by void in a major release*/; } // @public diff --git a/packages/core/src/linker/view_ref.ts b/packages/core/src/linker/view_ref.ts index 315f86e6d77..63c9c699e39 100644 --- a/packages/core/src/linker/view_ref.ts +++ b/packages/core/src/linker/view_ref.ts @@ -33,7 +33,7 @@ export abstract class ViewRef extends ChangeDetectorRef { * @param callback A handler function that cleans up developer-defined data * associated with a view. Called when the `destroy()` method is invoked. */ - abstract onDestroy(callback: Function): any /** TODO #9100 */; + abstract onDestroy(callback: Function): any /** TODO #9100, replace by void in a major release*/; } /** diff --git a/packages/core/src/util/global.ts b/packages/core/src/util/global.ts index 2ee32b03815..2bc1ce2296e 100644 --- a/packages/core/src/util/global.ts +++ b/packages/core/src/util/global.ts @@ -7,11 +7,11 @@ */ // TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492 -declare var WorkerGlobalScope: any /** TODO #9100 */; +declare var WorkerGlobalScope: any; // CommonJS / Node have global context exposed as "global" variable. // We don't want to include the whole node.d.ts this this compilation unit so we'll just fake // the global "global" var for now. -declare var global: any /** TODO #9100 */; +declare var global: any; // Always use __globalThis if available, which is the spec-defined global variable across all // environments, then fallback to __global first, because in Node tests both __global and diff --git a/packages/core/test/di/reflective_injector_spec.ts b/packages/core/test/di/reflective_injector_spec.ts index 03f011d6de5..d68190033ce 100644 --- a/packages/core/test/di/reflective_injector_spec.ts +++ b/packages/core/test/di/reflective_injector_spec.ts @@ -493,11 +493,9 @@ describe('resolve', () => { }); it('should support overriding factory dependencies with dependency annotations', () => { - const providers = ReflectiveInjector.resolve([{ - provide: 'token', - useFactory: (e: any /** TODO #9100 */) => 'result', - deps: [[new Inject('dep')]] - }]); + const providers = ReflectiveInjector.resolve([ + {provide: 'token', useFactory: () => 'result', deps: [[new Inject('dep')]]}, + ]); const provider = providers[0]; diff --git a/packages/core/test/directive_lifecycle_integration_spec.ts b/packages/core/test/directive_lifecycle_integration_spec.ts index b9408fae4ef..0f59cdf6eb5 100644 --- a/packages/core/test/directive_lifecycle_integration_spec.ts +++ b/packages/core/test/directive_lifecycle_integration_spec.ts @@ -64,10 +64,10 @@ class LifecycleDir implements DoCheck { }) class LifecycleCmp implements OnChanges, OnInit, DoCheck, AfterContentInit, AfterContentChecked, AfterViewInit, AfterViewChecked { - field: any /** TODO #9100 */; + field: number = 0; constructor(private _log: Log) {} - ngOnChanges(_: any /** TODO #9100 */) { + ngOnChanges() { this._log.add('ngOnChanges'); } diff --git a/packages/core/test/dom/shim_spec.ts b/packages/core/test/dom/shim_spec.ts index 9f39856cef9..ab37f6d7ec8 100644 --- a/packages/core/test/dom/shim_spec.ts +++ b/packages/core/test/dom/shim_spec.ts @@ -13,15 +13,15 @@ import '@angular/core/testing'; { describe('Shim', () => { it('should provide correct function.name ', () => { - const functionWithoutName = identity(() => function(_: any /** TODO #9100 */) {}); - function foo(_: any /** TODO #9100 */) {} + const functionWithoutName = identity(() => function() {}); + function foo() {} - expect((functionWithoutName).name).toBeFalsy(); - expect((foo).name).toEqual('foo'); + expect(functionWithoutName.name).toBeFalsy(); + expect(foo.name).toEqual('foo'); }); }); } -function identity(a: any /** TODO #9100 */) { +function identity(a: T): T { return a; } diff --git a/packages/core/test/event_emitter_spec.ts b/packages/core/test/event_emitter_spec.ts index 3715b0fc1b3..7a9ce90401d 100644 --- a/packages/core/test/event_emitter_spec.ts +++ b/packages/core/test/event_emitter_spec.ts @@ -12,18 +12,16 @@ import {EventEmitter} from '../src/event_emitter'; { describe('EventEmitter', () => { - let emitter: EventEmitter; + let emitter: EventEmitter; beforeEach(() => { emitter = new EventEmitter(); }); it('should call the next callback', done => { - emitter.subscribe({ - next: (value: any) => { - expect(value).toEqual(99); - done(); - } + emitter.subscribe((value: number) => { + expect(value).toEqual(99); + done(); }); emitter.emit(99); }); @@ -42,7 +40,7 @@ import {EventEmitter} from '../src/event_emitter'; it('should work when no throw callback is provided', done => { emitter.subscribe({ next: () => {}, - error: (_: any) => { + error: () => { done(); } }); @@ -52,7 +50,7 @@ import {EventEmitter} from '../src/event_emitter'; it('should call the return callback', done => { emitter.subscribe({ next: () => {}, - error: (_: any) => {}, + error: () => {}, complete: () => { done(); } @@ -63,7 +61,7 @@ import {EventEmitter} from '../src/event_emitter'; it('should subscribe to the wrapper synchronously', () => { let called = false; emitter.subscribe({ - next: (value: any) => { + next: () => { called = true; } }); @@ -73,19 +71,18 @@ import {EventEmitter} from '../src/event_emitter'; }); it('delivers next and error events synchronously', done => { - const log: any[] /** TODO #9100 */ = []; + const log: number[] = []; - emitter.subscribe({ - next: (x: any) => { - log.push(x); - expect(log).toEqual([1, 2]); - }, - error: (err: any) => { - log.push(err); - expect(log).toEqual([1, 2, 3, 4]); - done(); - } - }); + emitter.subscribe( + (x: number) => { + log.push(x); + expect(log).toEqual([1, 2]); + }, + (err: any) => { + log.push(err); + expect(log).toEqual([1, 2, 3, 4]); + done(); + }); log.push(1); emitter.emit(2); log.push(3); @@ -94,14 +91,14 @@ import {EventEmitter} from '../src/event_emitter'; }); it('delivers next and complete events synchronously', () => { - const log: any[] /** TODO #9100 */ = []; + const log: number[] = []; emitter.subscribe({ - next: (x: any) => { + next: (x: number) => { log.push(x); expect(log).toEqual([1, 2]); }, - error: null, + error: undefined, complete: () => { log.push(4); expect(log).toEqual([1, 2, 3, 4]); @@ -116,9 +113,9 @@ import {EventEmitter} from '../src/event_emitter'; }); it('delivers events asynchronously when forced to async mode', done => { - const e = new EventEmitter(true); - const log: any[] /** TODO #9100 */ = []; - e.subscribe((x: any) => { + const e = new EventEmitter(true); + const log: number[] = []; + e.subscribe((x) => { log.push(x); expect(log).toEqual([1, 3, 2]); done(); diff --git a/packages/core/test/fake_async_spec.ts b/packages/core/test/fake_async_spec.ts index 705d34669ca..0171f0a1727 100644 --- a/packages/core/test/fake_async_spec.ts +++ b/packages/core/test/fake_async_spec.ts @@ -26,7 +26,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' }); it('should pass arguments to the wrapped function', () => { - fakeAsync((foo: any /** TODO #9100 */, bar: any /** TODO #9100 */) => { + fakeAsync((foo: string, bar: string) => { expect(foo).toEqual('foo'); expect(bar).toEqual('bar'); })('foo', 'bar'); @@ -40,7 +40,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' it('should throw on nested calls', () => { expect(() => { fakeAsync(() => { - fakeAsync((): any /** TODO #9100 */ => null)(); + fakeAsync((): null => null)(); })(); }).toThrowError('fakeAsync() calls can not be nested'); }); @@ -76,7 +76,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' })); it('should run chained thens', fakeAsync(() => { - const log = new Log(); + const log = new Log(); resolvedPromise.then((_) => log.add(1)).then((_) => log.add(2)); @@ -87,7 +87,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' })); it('should run Promise created in Promise', fakeAsync(() => { - const log = new Log(); + const log = new Log(); resolvedPromise.then((_) => { log.add(1); @@ -245,9 +245,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' it('should be able to cancel periodic timers from a callback', fakeAsync(() => { let cycles = 0; - let id: any /** TODO #9100 */; - - id = setInterval(() => { + const id = setInterval(() => { cycles++; clearInterval(id); }, 10); @@ -261,7 +259,7 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec' it('should clear periodic timers', fakeAsync(() => { let cycles = 0; - const id = setInterval(() => { + setInterval(() => { cycles++; }, 10); diff --git a/packages/core/test/linker/query_integration_spec.ts b/packages/core/test/linker/query_integration_spec.ts index 297a9162703..67678cb8f03 100644 --- a/packages/core/test/linker/query_integration_spec.ts +++ b/packages/core/test/linker/query_integration_spec.ts @@ -744,7 +744,7 @@ class NeedsContentChild implements AfterContentInit, AfterContentChecked { get child() { return this._child; } - logs: any[] /** TODO #9100 */ = []; + logs: (string|null)[][] = []; ngAfterContentInit() { this.logs.push(['init', this.child ? this.child.text : null]); @@ -778,7 +778,7 @@ class NeedsViewChild implements AfterViewInit, AfterViewChecked { get child() { return this._child; } - logs: any[] /** TODO #9100 */ = []; + logs: (string|null)[][] = []; ngAfterViewInit() { this.logs.push(['init', this.child ? this.child.text : null]); diff --git a/packages/core/test/linker/query_list_spec.ts b/packages/core/test/linker/query_list_spec.ts index 7b03e7779e9..815e9b31008 100644 --- a/packages/core/test/linker/query_list_spec.ts +++ b/packages/core/test/linker/query_list_spec.ts @@ -20,7 +20,7 @@ import {fakeAsync, tick} from '@angular/core/testing'; log = ''; }); - function logAppend(item: any /** TODO #9100 */) { + function logAppend(item: string) { log += (log.length == 0 ? '' : ', ') + item; } @@ -177,7 +177,7 @@ import {fakeAsync, tick} from '@angular/core/testing'; })); it('should provides query list as an argument', fakeAsync(() => { - let recorded: any /** TODO #9100 */; + let recorded: any; /** TODO #9100, replace with QueryList when #48004 is merged */ queryList.changes.subscribe({ next: (v: any) => { recorded = v; diff --git a/packages/core/testing/src/component_fixture.ts b/packages/core/testing/src/component_fixture.ts index 6cd2853d61b..3d53df2b301 100644 --- a/packages/core/testing/src/component_fixture.ts +++ b/packages/core/testing/src/component_fixture.ts @@ -7,6 +7,7 @@ */ import {ChangeDetectorRef, ComponentRef, DebugElement, ElementRef, getDebugNode, NgZone, RendererFactory2} from '@angular/core'; +import {Subscription} from 'rxjs'; /** @@ -43,12 +44,12 @@ export class ComponentFixture { private _renderer: RendererFactory2|null|undefined; private _isStable: boolean = true; private _isDestroyed: boolean = false; - private _resolve: ((result: any) => void)|null = null; - private _promise: Promise|null = null; - private _onUnstableSubscription: any /** TODO #9100 */ = null; - private _onStableSubscription: any /** TODO #9100 */ = null; - private _onMicrotaskEmptySubscription: any /** TODO #9100 */ = null; - private _onErrorSubscription: any /** TODO #9100 */ = null; + private _resolve: ((result: boolean) => void)|null = null; + private _promise: Promise|null = null; + private _onUnstableSubscription: Subscription|null = null; + private _onStableSubscription: Subscription|null = null; + private _onMicrotaskEmptySubscription: Subscription|null = null; + private _onErrorSubscription: Subscription|null = null; constructor( public componentRef: ComponentRef, public ngZone: NgZone|null, diff --git a/packages/core/testing/src/lang_utils.ts b/packages/core/testing/src/lang_utils.ts deleted file mode 100644 index 0091fdae248..00000000000 --- a/packages/core/testing/src/lang_utils.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - -export function getTypeOf(instance: any /** TODO #9100 */) { - return instance.constructor; -} - -export function instantiateType(type: Function, params: any[] = []) { - return new (type)(...params); -} diff --git a/packages/core/testing/src/logger.ts b/packages/core/testing/src/logger.ts index 65b482a7612..5efaf3f6d00 100644 --- a/packages/core/testing/src/logger.ts +++ b/packages/core/testing/src/logger.ts @@ -9,19 +9,19 @@ import {Injectable} from '@angular/core'; @Injectable() -export class Log { - logItems: any[]; +export class Log { + logItems: T[]; constructor() { this.logItems = []; } - add(value: any /** TODO #9100 */): void { + add(value: T): void { this.logItems.push(value); } - fn(value: any /** TODO #9100 */) { - return (a1: any = null, a2: any = null, a3: any = null, a4: any = null, a5: any = null) => { + fn(value: T) { + return () => { this.logItems.push(value); }; }