From 6f8ca80377216a8691b2630cd2b119f06da1b8b3 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 15:06:31 -0300 Subject: [PATCH 1/5] adding country-select-js typings --- .../country-select-js-tests.ts | 1 + types/country-select-js/index.d.ts | 55 +++++++++++++++++++ types/country-select-js/tsconfig.json | 23 ++++++++ types/country-select-js/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/country-select-js/country-select-js-tests.ts create mode 100644 types/country-select-js/index.d.ts create mode 100644 types/country-select-js/tsconfig.json create mode 100644 types/country-select-js/tslint.json diff --git a/types/country-select-js/country-select-js-tests.ts b/types/country-select-js/country-select-js-tests.ts new file mode 100644 index 0000000000..145dda23b2 --- /dev/null +++ b/types/country-select-js/country-select-js-tests.ts @@ -0,0 +1 @@ +$('#country').countrySelect(); diff --git a/types/country-select-js/index.d.ts b/types/country-select-js/index.d.ts new file mode 100644 index 0000000000..6aea963e0d --- /dev/null +++ b/types/country-select-js/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for country-select-js 1.0 +// Project: https://github.com/mrmarkfrench/country-select-js +// Definitions by: Humberto Rocha +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace CountrySelectJs { + interface Options { + /** + * Set the default country by it's country code. Otherwise it will just be + * the first country in the list. + */ + defaultCountry?: string; + + /** + * Display only the countries you specify. Takes an array of country codes. + */ + onlyCountries?: string[]; + + /** + * Specify the countries to appear at the top of the list. Defaults to + * ["us", "gb"] + */ + preferredCountries?: string[]; + + /** + * Set the dropdown's width to be the same as the input. This is + * automatically enabled for small screens. + */ + responsiveDropdown?: boolean; + } + + interface CountryData { + name: string; + iso2: string; + } +} + +interface JQuery { + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + countrySelect(method: 'destroy'): void; + + /** + * Get the country data for the currently selected flag. + */ + countrySelect(method: 'getSelectedCountryData'): CountrySelectJs.CountryData; + + countrySelect(method: string, value: string): void; + + /** + * initialize the plugin with optional options. + */ + countrySelect(options?: CountrySelectJs.Options): JQueryDeferred; +} diff --git a/types/country-select-js/tsconfig.json b/types/country-select-js/tsconfig.json new file mode 100644 index 0000000000..807376d634 --- /dev/null +++ b/types/country-select-js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "country-select-js-tests.ts" + ] +} diff --git a/types/country-select-js/tslint.json b/types/country-select-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/country-select-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From deccd7e7e8d89564088205634ff9cc92f969c581 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 16:46:54 -0300 Subject: [PATCH 2/5] add more tests for country-select-js --- types/country-select-js/country-select-js-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/country-select-js/country-select-js-tests.ts b/types/country-select-js/country-select-js-tests.ts index 145dda23b2..066ff53500 100644 --- a/types/country-select-js/country-select-js-tests.ts +++ b/types/country-select-js/country-select-js-tests.ts @@ -1 +1,7 @@ $('#country').countrySelect(); + +$('#country').countrySelect({ + 'defaultCountry': 'gb' +}); + +$('#country').countrySelect('destroy'); From 19147d0035d54100483fab88825acbe0102f4305 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 16:50:47 -0300 Subject: [PATCH 3/5] add missing reference to jquery --- types/country-select-js/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/country-select-js/index.d.ts b/types/country-select-js/index.d.ts index 6aea963e0d..72c33489c2 100644 --- a/types/country-select-js/index.d.ts +++ b/types/country-select-js/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Humberto Rocha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + declare namespace CountrySelectJs { interface Options { /** From dbde7c423fadbd49b21efa09e62408901c595974 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 16:52:37 -0300 Subject: [PATCH 4/5] remove unnecessary property quotes --- types/country-select-js/country-select-js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/country-select-js/country-select-js-tests.ts b/types/country-select-js/country-select-js-tests.ts index 066ff53500..a3bf640b69 100644 --- a/types/country-select-js/country-select-js-tests.ts +++ b/types/country-select-js/country-select-js-tests.ts @@ -1,7 +1,7 @@ $('#country').countrySelect(); $('#country').countrySelect({ - 'defaultCountry': 'gb' + defaultCountry: 'gb' }); $('#country').countrySelect('destroy'); From 9d6acd7df2acea9e5ead95b5b8261a0f7197364c Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 17:09:40 -0300 Subject: [PATCH 5/5] set strictNullChecks to true --- types/country-select-js/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/country-select-js/tsconfig.json b/types/country-select-js/tsconfig.json index 807376d634..749b1b3af1 100644 --- a/types/country-select-js/tsconfig.json +++ b/types/country-select-js/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../"