diff options
| author | ST-DDT <[email protected]> | 2022-04-03 16:03:12 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-03 14:03:12 +0000 |
| commit | 214a77b437aaff1282248a6ee14fd227d5e42c42 (patch) | |
| tree | c2cd79c8d36c95d3d8d1019f5bc269552009f85c /src | |
| parent | 52ad16ebe424cfe1acf7be1e98c9671baf8d1576 (diff) | |
| download | faker-214a77b437aaff1282248a6ee14fd227d5e42c42.tar.xz faker-214a77b437aaff1282248a6ee14fd227d5e42c42.zip | |
chore: address zipCodeByState fix types (#760)
Diffstat (limited to 'src')
| -rw-r--r-- | src/address.ts | 13 | ||||
| -rw-r--r-- | src/definitions/address.ts | 5 | ||||
| -rw-r--r-- | src/locales/ar/address/index.ts | 2 | ||||
| -rw-r--r-- | src/locales/ar/address/postcode_by_state.ts | 1 | ||||
| -rw-r--r-- | src/locales/en/address/index.ts | 2 | ||||
| -rw-r--r-- | src/locales/en/address/postcode_by_state.ts | 1 | ||||
| -rw-r--r-- | src/locales/he/address/index.ts | 2 | ||||
| -rw-r--r-- | src/locales/he/address/postcode_by_state.ts | 1 | ||||
| -rw-r--r-- | src/locales/ur/address/index.ts | 2 | ||||
| -rw-r--r-- | src/locales/ur/address/postcode_by_state.ts | 1 |
10 files changed, 7 insertions, 23 deletions
diff --git a/src/address.ts b/src/address.ts index d8dfbbbb..246f4d9b 100644 --- a/src/address.ts +++ b/src/address.ts @@ -84,8 +84,8 @@ export class Address { } /** - * Generates random zipcode from specified format. If format is not specified, the - * locale's zip format is used. + * Generates random zip code from specified format. If format is not specified, + * the locale's zip format is used. * * @param format The optional format used to generate the the zip code. * By default, a random format is used from the locale zip formats. @@ -111,7 +111,7 @@ export class Address { } /** - * Generates random zipcode from state abbreviation. If state abbreviation is + * Generates random zip code from state abbreviation. If state abbreviation is * not specified, a random zip code is generated according to the locale's zip format. * Only works for locales with postcode_by_state definition. If a locale does not * have a postcode_by_state definition, a random zip code is generated according @@ -123,11 +123,10 @@ export class Address { * fakerUS.address.zipCodeByState("AK") // '99595' * fakerUS.address.zipCodeByState("??") // '47683-9880' */ - zipCodeByState(state: string): string | number { - const zipRange = this.faker.definitions.address.postcode_by_state[state]; + zipCodeByState(state: string): string { + const zipRange = this.faker.definitions.address.postcode_by_state?.[state]; if (zipRange) { - // TODO ST-DDT 2022-02-10: Fix types - return this.faker.datatype.number(zipRange); + return String(this.faker.datatype.number(zipRange)); } return this.faker.address.zipCode(); } diff --git a/src/definitions/address.ts b/src/definitions/address.ts index d34bc0bd..24f9b7cc 100644 --- a/src/definitions/address.ts +++ b/src/definitions/address.ts @@ -7,10 +7,7 @@ export interface AddressDefinitions { /** * Postcodes patterns by state */ - // TODO ST-DDT 2022-01-31: address.zipCodeByState() expects only { [state: string]: { min: number; max: number } } - postcode_by_state: - | string[] - | { [state: string]: { min: number; max: number } }; + postcode_by_state: { [state: string]: { min: number; max: number } }; /** * Postcodes patterns (Fake-Pattern | Fake-Pattern[]). */ diff --git a/src/locales/ar/address/index.ts b/src/locales/ar/address/index.ts index 4506fbc8..7789c0e5 100644 --- a/src/locales/ar/address/index.ts +++ b/src/locales/ar/address/index.ts @@ -9,7 +9,6 @@ import city_name from './city_name'; import country from './country'; import default_country from './default_country'; import postcode from './postcode'; -import postcode_by_state from './postcode_by_state'; import secondary_address from './secondary_address'; import state from './state'; import street_address from './street_address'; @@ -23,7 +22,6 @@ const address = { country, default_country, postcode, - postcode_by_state, secondary_address, state, street_address, diff --git a/src/locales/ar/address/postcode_by_state.ts b/src/locales/ar/address/postcode_by_state.ts deleted file mode 100644 index 4433f068..00000000 --- a/src/locales/ar/address/postcode_by_state.ts +++ /dev/null @@ -1 +0,0 @@ -export default ['#####', '#####-####']; diff --git a/src/locales/en/address/index.ts b/src/locales/en/address/index.ts index efb55311..78cb3ec8 100644 --- a/src/locales/en/address/index.ts +++ b/src/locales/en/address/index.ts @@ -16,7 +16,6 @@ import default_country from './default_country'; import direction from './direction'; import direction_abbr from './direction_abbr'; import postcode from './postcode'; -import postcode_by_state from './postcode_by_state'; import secondary_address from './secondary_address'; import state from './state'; import state_abbr from './state_abbr'; @@ -39,7 +38,6 @@ const address = { direction, direction_abbr, postcode, - postcode_by_state, secondary_address, state, state_abbr, diff --git a/src/locales/en/address/postcode_by_state.ts b/src/locales/en/address/postcode_by_state.ts deleted file mode 100644 index 4433f068..00000000 --- a/src/locales/en/address/postcode_by_state.ts +++ /dev/null @@ -1 +0,0 @@ -export default ['#####', '#####-####']; diff --git a/src/locales/he/address/index.ts b/src/locales/he/address/index.ts index 04ed969d..bcf2af27 100644 --- a/src/locales/he/address/index.ts +++ b/src/locales/he/address/index.ts @@ -13,7 +13,6 @@ import default_country from './default_country'; import direction from './direction'; import direction_abbr from './direction_abbr'; import postcode from './postcode'; -import postcode_by_state from './postcode_by_state'; import secondary_address from './secondary_address'; import state from './state'; import state_abbr from './state_abbr'; @@ -33,7 +32,6 @@ const address = { direction, direction_abbr, postcode, - postcode_by_state, secondary_address, state, state_abbr, diff --git a/src/locales/he/address/postcode_by_state.ts b/src/locales/he/address/postcode_by_state.ts deleted file mode 100644 index 2850dba4..00000000 --- a/src/locales/he/address/postcode_by_state.ts +++ /dev/null @@ -1 +0,0 @@ -export default ['#####', '#######']; diff --git a/src/locales/ur/address/index.ts b/src/locales/ur/address/index.ts index 312e9027..a04af907 100644 --- a/src/locales/ur/address/index.ts +++ b/src/locales/ur/address/index.ts @@ -12,7 +12,6 @@ import country from './country'; import default_country from './default_country'; import direction from './direction'; import postcode from './postcode'; -import postcode_by_state from './postcode_by_state'; import secondary_address from './secondary_address'; import state from './state'; import state_abbr from './state_abbr'; @@ -30,7 +29,6 @@ const address = { default_country, direction, postcode, - postcode_by_state, secondary_address, state, state_abbr, diff --git a/src/locales/ur/address/postcode_by_state.ts b/src/locales/ur/address/postcode_by_state.ts deleted file mode 100644 index db2bcfed..00000000 --- a/src/locales/ur/address/postcode_by_state.ts +++ /dev/null @@ -1 +0,0 @@ -export default ['#####']; |
