diff --git a/packages/common/src/pipes/keyvalue_pipe.ts b/packages/common/src/pipes/keyvalue_pipe.ts index ef0eb5f5a6..5770f6a75b 100644 --- a/packages/common/src/pipes/keyvalue_pipe.ts +++ b/packages/common/src/pipes/keyvalue_pipe.ts @@ -47,10 +47,8 @@ export interface KeyValue { export class KeyValuePipe implements PipeTransform { constructor(private readonly differs: KeyValueDiffers) {} - // TODO(issue/24571): remove '!'. private differ !: KeyValueDiffer; - // TODO(issue/24571): remove '!'. - private keyValues !: Array>; + private keyValues: Array> = []; transform(input: null, compareFn?: (a: KeyValue, b: KeyValue) => number): null; transform( diff --git a/packages/common/test/pipes/keyvalue_pipe_spec.ts b/packages/common/test/pipes/keyvalue_pipe_spec.ts index e9f1c53bfc..5d69e9929a 100644 --- a/packages/common/test/pipes/keyvalue_pipe_spec.ts +++ b/packages/common/test/pipes/keyvalue_pipe_spec.ts @@ -25,6 +25,10 @@ describe('KeyValuePipe', () => { expect(pipe.transform(fn as any)).toEqual(null); }); describe('object dictionary', () => { + it('should return empty array of an empty dictionary', () => { + const pipe = new KeyValuePipe(defaultKeyValueDiffers); + expect(pipe.transform({})).toEqual([]); + }); it('should transform a basic dictionary', () => { const pipe = new KeyValuePipe(defaultKeyValueDiffers); expect(pipe.transform({1: 2})).toEqual([{key: '1', value: 2}]); @@ -62,6 +66,10 @@ describe('KeyValuePipe', () => { }); describe('Map', () => { + it('should return an empty array for an empty Map', () => { + const pipe = new KeyValuePipe(defaultKeyValueDiffers); + expect(pipe.transform(new Map())).toEqual([]); + }); it('should transform a basic Map', () => { const pipe = new KeyValuePipe(defaultKeyValueDiffers); expect(pipe.transform(new Map([[1, 2]]))).toEqual([{key: 1, value: 2}]);