Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: invalid number can set undefined as a type #110

Closed
Hakier opened this issue Nov 1, 2023 · 1 comment
Closed

Bug: invalid number can set undefined as a type #110

Hakier opened this issue Nov 1, 2023 · 1 comment

Comments

@Hakier
Copy link

Hakier commented Nov 1, 2023

const {parsePhoneNumber} = require('awesome-phonenumber'); //v6.1.0
const parsed = parsePhoneNumber('7185555555');
expect(parsed.type).to.eql(undefined); // this passes but should not

type is not not optional

interface ParsedPhoneNumberFull {
...
type: PhoneNumberTypes;
}

and it is not specifying undefined

export type PhoneNumberTypes =
	| 'fixed-line'
	| 'fixed-line-or-mobile'
	| 'mobile'
	| 'pager'
	| 'personal-number'
	| 'premium-rate'
	| 'shared-cost'
	| 'toll-free'
	| 'uan'
	| 'voip'
	| 'unknown';
@grantila
Copy link
Owner

This is fixed in newer versions, it should default to unknown for invalid phone numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants