From 40bacbfde090e928f888d2e5566437f6c5918f0a Mon Sep 17 00:00:00 2001 From: William Lohan Date: Tue, 26 Dec 2017 12:47:53 -0800 Subject: [PATCH 1/2] add provinces package --- types/provinces/index.d.ts | 39 ++++++++++++++++++++++++++++++ types/provinces/provinces-tests.ts | 16 ++++++++++++ types/provinces/tsconfig.json | 23 ++++++++++++++++++ types/provinces/tslint.json | 6 +++++ 4 files changed, 84 insertions(+) create mode 100644 types/provinces/index.d.ts create mode 100644 types/provinces/provinces-tests.ts create mode 100644 types/provinces/tsconfig.json create mode 100644 types/provinces/tslint.json 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..1e30988418 --- /dev/null +++ b/types/provinces/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-var-requires": false + } +} From 0f74394e27e883a6945874b5ca73121de2008ebc Mon Sep 17 00:00:00 2001 From: William Lohan Date: Wed, 27 Dec 2017 15:35:12 -0800 Subject: [PATCH 2/2] remove custom tslint rules --- types/provinces/tslint.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/provinces/tslint.json b/types/provinces/tslint.json index 1e30988418..f93cf8562a 100644 --- a/types/provinces/tslint.json +++ b/types/provinces/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "no-var-requires": false - } + "extends": "dtslint/dt.json" }