Skip to content

Commit 406ae85

Browse files
JeanMechealxhub
authored andcommitted
refactor(common): code cleaning (#48476)
* 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) PR Close #48476
1 parent be321f0 commit 406ae85

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/common/src/directives/ng_for_of.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,9 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
168168
@Input()
169169
set ngForTrackBy(fn: TrackByFunction<T>) {
170170
if (NG_DEV_MODE && fn != null && typeof fn !== 'function') {
171-
// TODO(vicb): use a log service once there is a public one available
172-
if (<any>console && <any>console.warn) {
173-
console.warn(
174-
`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
175-
`See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
176-
}
171+
console.warn(
172+
`trackBy must be a function, but received ${JSON.stringify(fn)}. ` +
173+
`See https://angular.io/api/common/NgForOf#change-propagation for more information.`);
177174
}
178175
this._trackByFn = fn;
179176
}
@@ -185,7 +182,9 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
185182
private _ngForOf: U|undefined|null = null;
186183
private _ngForOfDirty: boolean = true;
187184
private _differ: IterableDiffer<T>|null = null;
188-
// TODO(issue/24571): remove '!'.
185+
// TODO(issue/24571): remove '!'
186+
// waiting for microsoft/typescript#43662 to allow the return type `TrackByFunction|undefined` for
187+
// the getter
189188
private _trackByFn!: TrackByFunction<T>;
190189

191190
constructor(

0 commit comments

Comments
 (0)