fix(common): correct typing and implementation of SlicePipe
(#37447)
Even in the overloads, state that it can accept `null` and `undefined`, in order to ensure easy composition with `async`. Additionally, change the implementation to return `null` on an `undefined` input, for consistency with other pipes. BREAKING CHANGE: The `slice` pipe now returns `null` for the `undefined` input value, which is consistent with the behavior of most pipes. If you rely on `undefined` being the result in that case, you now need to check for it explicitly. PR Close #37447
This commit is contained in:

committed by
Alex Rickabaugh

parent
4dfe0fa068
commit
4744c229db
@ -47,8 +47,8 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
expect(pipe.transform(null, 1)).toBe(null);
|
||||
});
|
||||
|
||||
it('should return undefined if the value is undefined', () => {
|
||||
expect(pipe.transform(undefined, 1)).toBe(undefined);
|
||||
it('should return null if the value is undefined', () => {
|
||||
expect(pipe.transform(undefined, 1)).toBe(null);
|
||||
});
|
||||
|
||||
it('should return all items after START index when START is positive and END is omitted',
|
||||
|
Reference in New Issue
Block a user