diff --git a/src/CountryPicker.d.ts b/src/CountryPicker.d.ts index 1c0e0e15..2d0b8b42 100644 --- a/src/CountryPicker.d.ts +++ b/src/CountryPicker.d.ts @@ -1,29 +1,298 @@ import { StyleProp, ViewStyle, ImageProps } from 'react-native'; import * as React from 'react'; -import countries from '../data/countries.json'; /** - * Country metadata stored in this library to display and query `` + * Country metadata stored in this library to display and query + * `` */ -export type Country = (typeof countries)[CCA2Code]; +export interface Country { + currency: CurrencyCode; + callingCode: CallingCode; + flag: string; + name: { [key in TranslationLanguageCode]: string }; +} + /** * Country code, as specified in ISO 3166-1 alpha-2 (ie. `FR`, `US`, etc.) */ -export type CCA2Code = keyof typeof countries; +export type CCA2Code = + | 'AF' + | 'AL' + | 'DZ' + | 'AS' + | 'AD' + | 'AO' + | 'AI' + | 'AQ' + | 'AG' + | 'AR' + | 'AM' + | 'AW' + | 'AU' + | 'AT' + | 'AZ' + | 'BS' + | 'BH' + | 'BD' + | 'BB' + | 'BY' + | 'BE' + | 'BZ' + | 'BJ' + | 'BM' + | 'BT' + | 'BO' + | 'BA' + | 'BW' + | 'BV' + | 'BR' + | 'IO' + | 'VG' + | 'BN' + | 'BG' + | 'BF' + | 'BI' + | 'KH' + | 'CM' + | 'CA' + | 'CV' + | 'KY' + | 'CF' + | 'TD' + | 'CL' + | 'CN' + | 'CX' + | 'CC' + | 'CO' + | 'KM' + | 'CK' + | 'CR' + | 'HR' + | 'CU' + | 'CW' + | 'CY' + | 'CZ' + | 'CD' + | 'DK' + | 'DJ' + | 'DM' + | 'DO' + | 'EC' + | 'EG' + | 'SV' + | 'GQ' + | 'ER' + | 'EE' + | 'ET' + | 'FK' + | 'FO' + | 'FJ' + | 'FI' + | 'FR' + | 'GF' + | 'PF' + | 'TF' + | 'GA' + | 'GM' + | 'GE' + | 'DE' + | 'GH' + | 'GI' + | 'GR' + | 'GL' + | 'GD' + | 'GP' + | 'GU' + | 'GT' + | 'GG' + | 'GN' + | 'GW' + | 'GY' + | 'HT' + | 'HM' + | 'HN' + | 'HK' + | 'HU' + | 'IS' + | 'IN' + | 'ID' + | 'IR' + | 'IQ' + | 'IE' + | 'IM' + | 'IL' + | 'IT' + | 'CI' + | 'JM' + | 'JP' + | 'JE' + | 'JO' + | 'KZ' + | 'KE' + | 'KI' + | 'XK' + | 'KW' + | 'KG' + | 'LA' + | 'LV' + | 'LB' + | 'LS' + | 'LR' + | 'LY' + | 'LI' + | 'LT' + | 'LU' + | 'MO' + | 'MK' + | 'MG' + | 'MW' + | 'MY' + | 'MV' + | 'ML' + | 'MT' + | 'MH' + | 'MQ' + | 'MR' + | 'MU' + | 'YT' + | 'MX' + | 'FM' + | 'MD' + | 'MC' + | 'MN' + | 'ME' + | 'MS' + | 'MA' + | 'MZ' + | 'MM' + | 'NA' + | 'NR' + | 'NP' + | 'NL' + | 'NC' + | 'NZ' + | 'NI' + | 'NE' + | 'NG' + | 'NU' + | 'NF' + | 'KP' + | 'MP' + | 'NO' + | 'OM' + | 'PK' + | 'PW' + | 'PS' + | 'PA' + | 'PG' + | 'PY' + | 'PE' + | 'PH' + | 'PN' + | 'PL' + | 'PT' + | 'PR' + | 'QA' + | 'CG' + | 'RO' + | 'RU' + | 'RW' + | 'RE' + | 'BL' + | 'KN' + | 'LC' + | 'MF' + | 'PM' + | 'VC' + | 'WS' + | 'SM' + | 'SA' + | 'SN' + | 'RS' + | 'SC' + | 'SL' + | 'SG' + | 'SX' + | 'SK' + | 'SI' + | 'SB' + | 'SO' + | 'ZA' + | 'GS' + | 'KR' + | 'SS' + | 'ES' + | 'LK' + | 'SD' + | 'SR' + | 'SJ' + | 'SZ' + | 'SE' + | 'CH' + | 'SY' + | 'ST' + | 'TW' + | 'TJ' + | 'TZ' + | 'TH' + | 'TL' + | 'TG' + | 'TK' + | 'TO' + | 'TT' + | 'TN' + | 'TR' + | 'TM' + | 'TC' + | 'TV' + | 'UG' + | 'UA' + | 'AE' + | 'GB' + | 'US' + | 'UM' + | 'VI' + | 'UY' + | 'UZ' + | 'VU' + | 'VA' + | 'VE' + | 'VN' + | 'WF' + | 'EH' + | 'YE' + | 'ZM' + | 'ZW' + | 'AX'; /** - * Calling code for a given country. For example: `United States (+1)` + * Calling code for a given country. For example, the entry for United States is + * `1` (referring to "+1`") */ export type CallingCode = string; /** - * Currency code for a country, as specified in ISO 4217. For example, US - * Dollars are `USD` + * Currency code for a country, as specified in ISO 4217. For example, the entry + * for United States is `USD` (referring to US Dollars) */ export type CurrencyCode = string; /** * Language codes for available translations in this library */ -export type TranslationLanguageCode = keyof Country['name']; +export type TranslationLanguageCode = + | 'common' + | 'cym' + | 'deu' + | 'fra' + | 'hrv' + | 'ita' + | 'jpn' + | 'nld' + | 'por' + | 'rus' + | 'spa' + | 'svk' + | 'fin' + | 'zho' + | 'isr'; export enum FlagType { FLAT = 'flat', diff --git a/tsconfig.json b/tsconfig.json index a5b1976a..78fcbc5e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,9 +15,6 @@ /* Additional Checks */ "noUnusedLocals": true /* Report errors on unused locals. */, "noUnusedParameters": true /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - - /* Module Resolution Options */ - "resolveJsonModule": true /* Resolve JSON modules to get types from JSON source data*/ + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */ } }