lucianoganga / country-codes-list Goto Github PK
View Code? Open in Web Editor NEWList of codes per country (languages, calling codes, currency codes, etc)
License: MIT License
List of codes per country (languages, calling codes, currency codes, etc)
License: MIT License
node_modules/country-codes-list/index.d.ts:60:8 - error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
60 ): { [CountryProperty]: string };
UM is reporting a country code of +246, expecting +1
+246 looks to be for British Indian Ocean Territories
Output: UM: '[UM] United States Minor Outlying Islands: +246',
Reference:
https://countrycode.org/britishindianoceanterritory
https://www.goldenchennai.com/isd-code/isd-code-for-us-minor-outlying-islands/
PR: #29
Are there intentions to add support for UK? I see that UK is a special case
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#UK
There is a interface for customList
to provide key, and this key is defined as CustomProperty enum. This enum is defined without const what means is not accessible in runtime. if i want to us customList
function and define key as you did in documentation i we got ts error
I could use correct value like this:
but const
in declaration is required to be able to use it in runtime
I started using this package and it doesn't have typings available which is annoying. If there are no typings available yet, i'll work on providing them for it. Just let me know.
I am using this awesome library with Typescript and came across customArray
.
Its just what I wanted, but it seems that the return type is string[]
.
Shouldn't it be something similar to {value: string, name: string}[]
?
Actual code in the package is "currencyCode": "VEF"
import countryCodes, { CountryProperty } from 'country-codes-list'
console.log(countryCodesList.CountryProperty.countryCode)
⨯ TypeError: Cannot read properties of undefined (reading 'countryCode')
node: v18.17.0
typescript: v5.4.2
From https://www.iso.org/iso-3166-country-codes.html, the following countries (yes they have registered codes, flags, etc... :-)) are missing:
Hello,
The computed property name type in the customList function might incorrect. Currently, the code attempts to use CountryProperty as a computed property name, but TypeScript throws an error because CountryProperty is not a literal type or a unique symbol type.
The corrected code can be
index.d.ts:60
export function customList(
key?: CountryProperty,
label?: string,
settings?: CustomArraySettings,
): { [K in CountryProperty]: string };
or
export function customList(
key?: CountryProperty,
label?: string,
settings?: CustomArraySettings,
): { [key: string]: string };
Library version: 1.6.11
Environment: [email protected]
I'm using the data from country codes to create a list, where each country is identified by the country code.
import countryCodes from 'country-codes-list';
const countryData = countryCodes.customArray({
id: '{countryCode}',
...
});
This list is then uses as select options, using the country code as a select option value. I'm getting the following error.
Encountered two children with the same key, `IO`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
This issue is specific to the select library that we're using, not directly to country-codes-list
, but highlights a problem that could be solved on the library level.
Going over the countries configuration file, there are two entries for IO
locale, which are the following:
https://github.com/LucianoGanga/country-codes-list/blob/master/countriesData.js#L1459
{
"countryNameEn": "British Indian Ocean Territories",
"countryNameLocal": "British Indian Ocean Territories",
"countryCode": "IO",
"currencyCode": "USD",
"currencyNameEn": "United States dollar",
"tinType": "",
"tinName": "",
"officialLanguageCode": "en",
"officialLanguageNameEn": "English",
"officialLanguageNameLocal": "English",
"countryCallingCode": "246",
"areaCodes": [],
"region": "Indian Ocean",
"flag": "🇮🇴",
}
https://github.com/LucianoGanga/country-codes-list/blob/master/countriesData.js#L3859
{
"countryNameEn": "British Indian Ocean Territory",
"countryNameLocal": "British Indian Ocean Territory",
"countryCode": "IO",
"currencyCode": "USD",
"currencyNameEn": "United States Dollar",
"tinType": "",
"tinName": "",
"officialLanguageCode": "en",
"officialLanguageNameEn": "English",
"officialLanguageNameLocal": "English",
"countryCallingCode": "246",
"areaCodes": [],
"region": "Indian Ocean",
"flag": "🇮🇴",
},
The only difference between these two entries is the name (Territories vs Territory), the rest of the data for these entries is identical.
Why are there two entries with the same country code? Do they represent different countries, even though all data associated with them is the same, expect for the name? Could we remove one of the two entries?
Country code is the field that's most likely to be used as the identifier / value in user interfaces. Often, they have to be unique to work properly, so perhaps it might be good to ensure there are no duplicates on the library level.
Use case is USA and Canada
So this code is broken
const countryCodes = require('country-codes-list')
let b = countryCodes.customList('countryCallingCode', '{countryCode}')
b[1] // yields 'DO'
one solution is to do map one country calling code to many country codes
The official language for Spain is Spanish es
.
It's set to ast
at the moment, which I didn't find much information on. Is it Asturian?
Here's the corrected entry:
{
"countryNameEn": "Spain",
"countryNameLocal": "España",
"countryCode": "ES",
"currencyCode": "EUR",
"currencyNameEn": "Euro",
"tinType": "NIF (CIF)",
"tinName": "Número de Identificación Fiscal (formerly named Código de Identificación Fiscal)",
"officialLanguageCode": "es",
"officialLanguageNameEn": "Spanish, Castilian",
"officialLanguageNameLocal": "Español",
"countryCallingCode": "34",
"areaCodes": [],
"region": "Europe",
"flag": "🇪🇸"
},
Spain must be Spain must be reviewed
Please provide Typescript example here or in the documentation, if possible.
It seems that for now some twitching is required to make types work.
At least these countries seem to be missing countryCallingCode
:
Can you please add these? Country calling codes from quick googling.
It would be useful to have the flag emoji for each country included as well.
hi,
could you please publish the newest version 1.6.10 (which includes the types) to npm?
thanks in advance and regards.
We are using this library inside of an Expo react-native
app (iOS, Android & Web) and when requesting the region code via the following mechanism we have received XA
from a Windows device on Chrome. After further investigation on this site XA appears to be the WorldBase 2 character representation for United Arab Emirates. Since we are not in control of what the operating system provides when asking for the region code we do not have a way of using a different ISO compliant region code.
Would it be possible to add the WorldBase 2 character country codes to this dataset?
import * as Localization from "expo-localization";
const regionCode = Localization.getLocales()?.[0]?.regionCode;
Hey there,
I was wondering if you'd been keen adding area codes / priorities for countries that have overlapping country codes. This would allow using this data for backing a phone picker, which also translates from phone number to country code.
See https://github.com/thegamenicorus/react-native-phone-input/blob/master/lib/resources/countries.json as an example.
I'll do a first kick-off with a PR that adds area codes for Canada based on https://en.wikipedia.org/wiki/Telephone_numbers_in_Canada. Let me know what you think.
Cheers,
Sascha
Hi,
I am new to node js programming and am trying to use your object:
var country = 'US';
const myCountryCodesObject = countryCodes.customList('countryCode', '{countryCode} +{countryCallingCode}');
var indx = myCountryCodesObject.indexOf(country);
console.log('index ' + indx);
I assume that customList returns a list... and I could do an indexOf that list... but it's not working...
Is there another way that I can get JUST the country code information for ONLY the country I am interested in ?
The country name should be changed to United Kingdom from Great Britain in countryNameEn
. It's known as the United Kingdom more than Great Britain. The countryNameLocal
can be Great Britain.
The various islands were united as a single country – the Netherlands Antilles – in 1954, under the Dutch crown. The country was dissolved on 10 October 2010.
It won't compile with the latest types that was added.
A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.
In index.d.ts
Issue happen in import.
index.js:70 Uncaught (in promise) ReferenceError: value is not defined
Index.js
value = supplant(label, countryData);
Should be
const value = supplant(label, countryData);
missing define value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.