From 162a48f2db4f2d56bec998d1cb1a10a0ddff2f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20R=C3=A4ntil=C3=A4?= Date: Sat, 25 Sep 2021 11:09:48 +0200 Subject: [PATCH] fix(typings): allow calling as function, even in TypeScript --- index.d.ts | 2 ++ test.in/awesome-phonenumber/should-compile.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/index.d.ts b/index.d.ts index e65f40c..372d3a5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -46,6 +46,8 @@ declare namespace AwesomePhonenumber static getAsYouType( regionCode: string ): AsYouType; } + function PhoneNumber( phoneNumber: string, countryCode?: string ): PhoneNumber; + class AsYouType { addChar( char: string ): string; diff --git a/test.in/awesome-phonenumber/should-compile.ts b/test.in/awesome-phonenumber/should-compile.ts index 3e15300..898dbbb 100644 --- a/test.in/awesome-phonenumber/should-compile.ts +++ b/test.in/awesome-phonenumber/should-compile.ts @@ -152,6 +152,19 @@ describe( 'general', function( ) { } ); +describe( 'instance', function( ) { + it( 'constructed should be instanceof PhoneNumber', function( ) { + var pn = new PhoneNumber( '+12' ); + expect( pn instanceof PhoneNumber ).to.be.true; + } ); + + it( 'called should be instanceof PhoneNumber', function( ) { + var pn = PhoneNumber( '+12' ); + expect( pn instanceof PhoneNumber ).to.be.true; + } ); +} ); + + describe( 'errors', function( ) { it( 'should not allow too short numbers', function( ) { var pn = new PhoneNumber( '+12' );