Skip to content

Commit

Permalink
fix(typings): allow calling as function, even in TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
grantila committed Sep 25, 2021
1 parent 99b201c commit 162a48f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions test.in/awesome-phonenumber/should-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 162a48f

Please sign in to comment.