Skip to content

Commit

Permalink
chore: update according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyYe committed May 24, 2024
1 parent d832869 commit b10179e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/shared/src/utils/phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down

0 comments on commit b10179e

Please sign in to comment.