libphonenumber-js 1.13.4 → 1.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libphonenumber-js",
3
- "version": "1.13.4",
3
+ "version": "1.13.6",
4
4
  "description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
package/types.d.cts CHANGED
@@ -87,40 +87,11 @@ export type PhoneNumberType = 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST' | 'VO
87
87
  */
88
88
  export type NumberType = PhoneNumberType | undefined;
89
89
 
90
- // "Tagged" types are used to introduce some degree of type safety when passing in arguments to the functions.
91
- // https://medium.com/@ethanresnick/advanced-typescript-tagged-types-for-fewer-bugs-and-better-security-24db681d5721
92
- //
93
- // For example, if some function returns an `E164Number`, it can only be interpreted as
94
- // either a `string` or an `E164Number` and it can't mistakenly be interpreted as
95
- // a `NationalNumber` or an `Extension` or a `CarrierCode` or a `CountryCallingCode`.
96
- //
97
- // Example:
98
- //
99
- // import type { E164Number, CarrierCode } from 'libphonenumber-js'
100
- // const number: E164Number = '+78005553535'
101
- // const carrierCode: CarrierCode = number
102
- //
103
- // Shows an error:
104
- // Type 'E164Number' is not assignable to type 'CarrierCode'.
105
- //
106
- // Originally, the `__tag` property was declared optional in order to allow passing
107
- // a generic `string` in place of a `Tagged` type argument to functions that receive such arguments:
108
- // that would allow ingesting generic `string` values from an outside source such as a database.
109
- // Without that, those externally-obtained `string` values would have to be forcefully converted
110
- // to the `Tagged` type via TypeScript `as` operator which is an anti-pattern.
111
- //
112
- // Later, it has been decided to make the `__tag` property non-optional and instead
113
- // declare the arguments of those functions as `string | Tagged` rather than just `Tagged`:
114
- // that would still allow ingesting generic `string` values from an outside source
115
- // and would also make the `Tagged` type more "type safe".
116
- //
117
- type Tagged<A, T> = A & { __tag: T };
118
-
119
- export type E164Number = Tagged<string, "E164Number">;
120
- export type NationalNumber = Tagged<string, "NationalNumber">;
121
- export type Extension = Tagged<string, "Extension">;
122
- export type CarrierCode = Tagged<string, "CarrierCode">;
123
- export type CountryCallingCode = Tagged<string, "CountryCallingCode">;
90
+ export type E164Number = string;
91
+ export type NationalNumber = string;
92
+ export type Extension = string;
93
+ export type CarrierCode = string;
94
+ export type CountryCallingCode = string;
124
95
 
125
96
  type FormatExtension = (formattedNumber: string, extension: Extension, metadata: MetadataJson) => string
126
97
 
package/types.d.ts CHANGED
@@ -87,40 +87,11 @@ export type PhoneNumberType = 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST' | 'VO
87
87
  */
88
88
  export type NumberType = PhoneNumberType | undefined;
89
89
 
90
- // "Tagged" types are used to introduce some degree of type safety when passing in arguments to the functions.
91
- // https://medium.com/@ethanresnick/advanced-typescript-tagged-types-for-fewer-bugs-and-better-security-24db681d5721
92
- //
93
- // For example, if some function returns an `E164Number`, it can only be interpreted as
94
- // either a `string` or an `E164Number` and it can't mistakenly be interpreted as
95
- // a `NationalNumber` or an `Extension` or a `CarrierCode` or a `CountryCallingCode`.
96
- //
97
- // Example:
98
- //
99
- // import type { E164Number, CarrierCode } from 'libphonenumber-js'
100
- // const number: E164Number = '+78005553535'
101
- // const carrierCode: CarrierCode = number
102
- //
103
- // Shows an error:
104
- // Type 'E164Number' is not assignable to type 'CarrierCode'.
105
- //
106
- // Originally, the `__tag` property was declared optional in order to allow passing
107
- // a generic `string` in place of a `Tagged` type argument to functions that receive such arguments:
108
- // that would allow ingesting generic `string` values from an outside source such as a database.
109
- // Without that, those externally-obtained `string` values would have to be forcefully converted
110
- // to the `Tagged` type via TypeScript `as` operator which is an anti-pattern.
111
- //
112
- // Later, it has been decided to make the `__tag` property non-optional and instead
113
- // declare the arguments of those functions as `string | Tagged` rather than just `Tagged`:
114
- // that would still allow ingesting generic `string` values from an outside source
115
- // and would also make the `Tagged` type more "type safe".
116
- //
117
- type Tagged<A, T> = A & { __tag: T };
118
-
119
- export type E164Number = Tagged<string, "E164Number">;
120
- export type NationalNumber = Tagged<string, "NationalNumber">;
121
- export type Extension = Tagged<string, "Extension">;
122
- export type CarrierCode = Tagged<string, "CarrierCode">;
123
- export type CountryCallingCode = Tagged<string, "CountryCallingCode">;
90
+ export type E164Number = string;
91
+ export type NationalNumber = string;
92
+ export type Extension = string;
93
+ export type CarrierCode = string;
94
+ export type CountryCallingCode = string;
124
95
 
125
96
  type FormatExtension = (formattedNumber: string, extension: Extension, metadata: MetadataJson) => string
126
97