From 157cf118d886e5b059e07a836d127598ebcfe635 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 24 Dec 2018 17:36:03 -0500 Subject: [PATCH] [intl-tel-input] Add `promise` property. --- types/intl-tel-input/index.d.ts | 2 ++ types/intl-tel-input/test/module-tests.ts | 27 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/types/intl-tel-input/index.d.ts b/types/intl-tel-input/index.d.ts index be705c86b6..f0c8407f18 100644 --- a/types/intl-tel-input/index.d.ts +++ b/types/intl-tel-input/index.d.ts @@ -37,6 +37,8 @@ declare namespace IntlTelInput { } interface Plugin { + promise: Promise; + /** * Remove the plugin from the input, and unbind any event listeners. */ diff --git a/types/intl-tel-input/test/module-tests.ts b/types/intl-tel-input/test/module-tests.ts index 13ee33c6e2..4bfdd3c6a7 100644 --- a/types/intl-tel-input/test/module-tests.ts +++ b/types/intl-tel-input/test/module-tests.ts @@ -1,9 +1,24 @@ import intlTelInput = require('intl-tel-input'); -// $ExpectType (node: Element, options?: Options) => Plugin -intlTelInput; +function test_import() { + // $ExpectType (node: Element, options?: Options) => Plugin + intlTelInput; +} -// $ExpectError -const options: IntlTelInput.Options = { - allowDropdown: true -}; +function test_IntlTelInput_not_visible() { + // $ExpectError + const options: IntlTelInput.Options = { + allowDropdown: true + }; +} + +function test_intlTelInputUtils_global() { + const input = document.querySelector('#phone'); + const iti = intlTelInput(input, { + utilsScript: 'node_modules/intl-tel-input/build/js/utils.js' + }); + + iti.promise.then(() => { + console.log(intlTelInputUtils.numberFormat.E164); + }); +}