From c4735c9fa6eba05e383c33a1dfb52ff61198d090 Mon Sep 17 00:00:00 2001 From: Christian Jensen Date: Fri, 18 Jun 2021 11:11:18 -0600 Subject: [PATCH] Add overloads to transform method Add the proper overloads to reflect the fact that this pipe will return a `string` if given a `string`, and a `string[]` if given a `string[]`. This provides accurate template-type checking. For example, if a hypothetical `giveMeAString` directive expects a string, using this pipe to provide that string would have previously resulted in an error since the pipe's type signature always returned `string | string[]`. ```html ``` --- projects/ngx-filesize/src/lib/filesize.pipe.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/ngx-filesize/src/lib/filesize.pipe.ts b/projects/ngx-filesize/src/lib/filesize.pipe.ts index 180416d2..d3749627 100644 --- a/projects/ngx-filesize/src/lib/filesize.pipe.ts +++ b/projects/ngx-filesize/src/lib/filesize.pipe.ts @@ -10,6 +10,8 @@ export class FileSizePipe implements PipeTransform { return filesize(value, options); } + transform(value: number, options?: any): string; + transform(value: number[], options?: any): string[]; transform(value: number | number[], options?: any) { if (Array.isArray(value)) { return value.map(val => FileSizePipe.transformOne(val, options));