From 1ed8c0a029287f52ae0c4653b34318a8b5715cbf Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Fri, 24 May 2024 16:56:46 +0800 Subject: [PATCH] chore: update according to comments --- packages/shared/src/utils/phone.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/utils/phone.ts b/packages/shared/src/utils/phone.ts index c55e5ff25..b158692d7 100644 --- a/packages/shared/src/utils/phone.ts +++ b/packages/shared/src/utils/phone.ts @@ -10,9 +10,13 @@ function validateE164Number(value: string): asserts value is E164Number { } const parseE164Number = (value: string): E164Number | '' => { - // If typeof `value` is string and `!value` is true, then `value` is an empty string. if (!value) { - return ''; + /** + * The type inference engine can not properly infer the type of the empty string, + * but using `string` instead. So we need to cast it. + */ + // eslint-disable-next-line no-restricted-syntax + return value as ''; } const result = value.startsWith('+') ? value : `+${value}`;