mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Updated country-list types to work with 2.1
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import countries from 'country-list';
|
||||
const Countries = countries();
|
||||
import * as Countries from 'country-list';
|
||||
|
||||
Countries.getCode('Barbados'); // BB
|
||||
|
||||
@@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados
|
||||
Countries.getNameList();
|
||||
|
||||
Countries.getNames();
|
||||
|
||||
Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]);
|
||||
|
||||
Vendored
+35
-31
@@ -1,41 +1,45 @@
|
||||
// Type definitions for country-list 1.1
|
||||
// Type definitions for country-list 2.1
|
||||
// Project: https://github.com/fannarsh/country-list
|
||||
// Definitions by: Kyle Roach <https://github.com/iRoachie>
|
||||
// Adam Binford <https://github.com/Kimahriman>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default function Countries(): {
|
||||
/**
|
||||
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getName(code: string): string | undefined;
|
||||
/**
|
||||
* Expects an array of code and country name pairs to add to the list. Doesn't return anything.
|
||||
*/
|
||||
export function overwrite(countries: Array<{ code: string, name: string}>): undefined;
|
||||
|
||||
/**
|
||||
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
|
||||
*/
|
||||
getCode(name: string): string | undefined;
|
||||
/**
|
||||
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
|
||||
*/
|
||||
export function getName(code: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns an array of all country names.
|
||||
*/
|
||||
getNames(): string[];
|
||||
/**
|
||||
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
|
||||
*/
|
||||
export function getCode(name: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns an array of all country codes.
|
||||
*/
|
||||
getCodes(): string[];
|
||||
/**
|
||||
* Returns an array of all country names.
|
||||
*/
|
||||
export function getNames(): string[];
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the name as key.
|
||||
*/
|
||||
getNameList(): {[name: string]: string};
|
||||
/**
|
||||
* Returns an array of all country codes.
|
||||
*/
|
||||
export function getCodes(): string[];
|
||||
|
||||
/**
|
||||
* Returns a key-value object of all countries using the code as key.
|
||||
*/
|
||||
getCodeList(): {[code: string]: string};
|
||||
/**
|
||||
* Returns a key-value object of all countries using the name as key.
|
||||
*/
|
||||
export function getNameList(): {[name: string]: string};
|
||||
|
||||
/**
|
||||
* Returns an array of all country information, in the same format as it gets imported.
|
||||
*/
|
||||
getData(): Array<{ code: string, name: string }>;
|
||||
};
|
||||
/**
|
||||
* Returns a key-value object of all countries using the code as key.
|
||||
*/
|
||||
export function getCodeList(): {[code: string]: string};
|
||||
|
||||
/**
|
||||
* Returns an array of all country information, in the same format as it gets imported.
|
||||
*/
|
||||
export function getData(): Array<{ code: string, name: string }>;
|
||||
|
||||
Reference in New Issue
Block a user