diff --git a/types/provinces/index.d.ts b/types/provinces/index.d.ts new file mode 100644 index 0000000000..2601d14da4 --- /dev/null +++ b/types/provinces/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for provinces 1.11 +// Project: https://github.com/substack/provinces +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare global { + /** + * @see {@link https://github.com/substack/provinces#data-format} + */ + interface Province { + /** + * full name of the province or state + */ + name: string; + /** + * country abbreviation + */ + country: string; + /** + * optional 2 or 3 character short name + */ + short?: string; + /** + * optional array of additional names and abbreviations + */ + alt?: string[]; + /** + * optional region of a country (for example: "Wales") + */ + region?: string; + } +} + +/** + * @see {@link https://github.com/substack/provinces#methods} + */ +declare const provinces: Province[]; + +export = provinces; diff --git a/types/provinces/provinces-tests.ts b/types/provinces/provinces-tests.ts new file mode 100644 index 0000000000..cd81d2d36a --- /dev/null +++ b/types/provinces/provinces-tests.ts @@ -0,0 +1,16 @@ +import * as provinces from 'provinces'; + +provinces.forEach((province: Province) => { + // https://github.com/substack/provinces#data-format + let name: string; + let country: string; + let short: string; + let alt: string[]; + let region: string; + + name = province.name; + country = province.country; + short = province.short ? province.short : ''; + alt = province.alt ? province.alt : []; + region = province.region ? province.region : ''; +}); diff --git a/types/provinces/tsconfig.json b/types/provinces/tsconfig.json new file mode 100644 index 0000000000..d08b599b71 --- /dev/null +++ b/types/provinces/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "provinces-tests.ts" + ] +} diff --git a/types/provinces/tslint.json b/types/provinces/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/provinces/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}