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
5
goldens/public-api/common/common.d.ts
vendored
5
goldens/public-api/common/common.d.ts
vendored
@ -381,9 +381,10 @@ export declare function registerLocaleData(data: any, localeId?: string | any, e
|
||||
|
||||
export declare class SlicePipe implements PipeTransform {
|
||||
transform<T>(value: ReadonlyArray<T>, start: number, end?: number): Array<T>;
|
||||
transform(value: null | undefined, start: number, end?: number): null;
|
||||
transform<T>(value: ReadonlyArray<T> | null | undefined, start: number, end?: number): Array<T> | null;
|
||||
transform(value: string, start: number, end?: number): string;
|
||||
transform(value: null, start: number, end?: number): null;
|
||||
transform(value: undefined, start: number, end?: number): undefined;
|
||||
transform(value: string | null | undefined, start: number, end?: number): string | null;
|
||||
}
|
||||
|
||||
export declare type Time = {
|
||||
|
Reference in New Issue
Block a user