grantila / awesome-phonenumber

Google's libphonenumber pre-compiled with the closure compiler
MIT License
661 stars 54 forks source link

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

Closed Hakier closed 2 months ago

Hakier commented 1 year ago
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 commented 2 months ago

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