Skip to content

Commit

Permalink
refactor(common): code cleaning (#48476)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JeanMeche authored and alxhub committed Jan 5, 2023
1 parent d832cb2 commit a8ba265
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/common/src/directives/ng_for_of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,9 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
@Input()
set ngForTrackBy(fn: TrackByFunction<T>) {
if (NG_DEV_MODE && fn != null && typeof fn !== 'function') {
// TODO(vicb): use a log service once there is a public one available
if (<any>console && <any>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;
}
Expand All @@ -185,7 +182,9 @@ export class NgForOf<T, U extends NgIterable<T> = NgIterable<T>> implements DoCh
private _ngForOf: U|undefined|null = null;
private _ngForOfDirty: boolean = true;
private _differ: IterableDiffer<T>|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<T>;

constructor(
Expand Down

0 comments on commit a8ba265

Please sign in to comment.