Added back v1 types

This commit is contained in:
Adam Binford
2018-11-19 12:33:59 -05:00
parent ebd2413635
commit a6b3615198
4 changed files with 84 additions and 0 deletions
@@ -0,0 +1,16 @@
import countries from 'country-list';
const Countries = countries();
Countries.getCode('Barbados'); // BB
Countries.getCodes();
Countries.getCodeList();
Countries.getData();
Countries.getName('BB'); // Barbados
Countries.getNameList();
Countries.getNames();
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for country-list 1.1
// Project: https://github.com/fannarsh/country-list
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// 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 the English country name. Returns the code for that country. If not found, it returns undefined.
*/
getCode(name: string): string | undefined;
/**
* Returns an array of all country names.
*/
getNames(): string[];
/**
* Returns an array of all country codes.
*/
getCodes(): string[];
/**
* Returns a key-value object of all countries using the name as key.
*/
getNameList(): {[name: string]: string};
/**
* Returns a key-value object of all countries using the code as key.
*/
getCodeList(): {[code: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
getData(): Array<{ code: string, name: string }>;
};
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"country-list": ["country-list/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"country-list-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }