0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

chore: update according to comments

This commit is contained in:
Darcy Ye 2024-05-24 16:56:46 +08:00
parent 6cc51d098b
commit 1ed8c0a029
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610

View file

@ -10,9 +10,13 @@ function validateE164Number(value: string): asserts value is E164Number {
} }
const parseE164Number = (value: string): E164Number | '' => { const parseE164Number = (value: string): E164Number | '' => {
// If typeof `value` is string and `!value` is true, then `value` is an empty string.
if (!value) { 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}`; const result = value.startsWith('+') ? value : `+${value}`;