From 6d2fb272ad04d41ba11d9607b9e30b32fa2177d2 Mon Sep 17 00:00:00 2001 From: Matthieu Riegler Date: Tue, 13 Dec 2022 18:16:35 +0100 Subject: [PATCH] refactor(common): code cleaning * removing guard as console.warn is now widely supported * Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/typescript#43662) --- packages/common/src/directives/ng_for_of.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/common/src/directives/ng_for_of.ts b/packages/common/src/directives/ng_for_of.ts index 205581224db0ad..0d3b21890b3707 100644 --- a/packages/common/src/directives/ng_for_of.ts +++ b/packages/common/src/directives/ng_for_of.ts @@ -168,12 +168,9 @@ export class NgForOf = NgIterable> implements DoCh @Input() set ngForTrackBy(fn: TrackByFunction) { if (NG_DEV_MODE && fn != null && typeof fn !== 'function') { - // TODO(vicb): use a log service once there is a public one available - if (console && console.warn) { - console.warn( - `trackBy must be a function, but received ${JSON.stringify(fn)}. ` + - `See https://angular.io/api/common/NgForOf#change-propagation for more information.`); - } + console.warn( + `trackBy must be a function, but received ${JSON.stringify(fn)}. ` + + `See https://angular.io/api/common/NgForOf#change-propagation for more information.`); } this._trackByFn = fn; } @@ -185,7 +182,9 @@ export class NgForOf = NgIterable> implements DoCh private _ngForOf: U|undefined|null = null; private _ngForOfDirty: boolean = true; private _differ: IterableDiffer|null = null; - // TODO(issue/24571): remove '!'. + // TODO(issue/24571): remove '!' + // waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for + // the getter private _trackByFn!: TrackByFunction; constructor(