fix(truncate-middle): null union type for str (#41277)

This fixes empty string return when param equals `null`:
https://git.io/JeNkz

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2020-01-03 21:50:19 +01:00
committed by Ryan Cavanaugh
parent d820013d4c
commit 35feaab6ae
2 changed files with 3 additions and 1 deletions

View File

@@ -3,6 +3,6 @@
// Definitions by: Gary King <https://github.com/garyking>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function truncateMiddle(text: string, frontLength?: number, backLength?: number, ellipsis?: string): string;
declare function truncateMiddle(text: string | null, frontLength?: number, backLength?: number, ellipsis?: string): string;
export = truncateMiddle;

View File

@@ -7,3 +7,5 @@ truncateMiddle('text', 1);
truncateMiddle('text', 1, 2);
truncateMiddle('text', 1, 2, '...');
truncateMiddle(null);