dhershman1 / phone-fns

A small modern, and functional phone number library
https://phone-fns.dusty.codes/
MIT License
16 stars 1 forks source link

Typings for Typescript #3

Closed hisham closed 5 years ago

hisham commented 5 years ago

Nice library! Would be nice to have typings for this lib for use in Typescript projects such as Angular apps. Can be added to the library itself or at https://github.com/DefinitelyTyped/DefinitelyTyped.

dhershman1 commented 5 years ago

Hey! Thanks for the suggestion, I'm not the most familiar with it but I attempted to add a index.d.ts file if you don't mind checking it out for me that'd be cool!

hisham commented 5 years ago

Thanks! I'll test it in the coming days with my actual app.

I did notice a couple things however after reviewing the code:

1) Instead of breakdown(phone: string): object, you can actually define another interface for object such as:

interface Breakdown {
  areaCode: string;
  localCode: string;
  lineNumber: string;
  extension: string;
}

And then the method would be breakdown(phone: string): Breakdown

2) Shouldn't isValid return boolean? If so then method should be isValid(phone: string): boolean

Thanks!

dhershman1 commented 5 years ago

Woops might've been a copy and paste error on number 2 there, and good idea for breakdown! I will certainly do that.

dhershman1 commented 5 years ago

It looks like the typing were working properly from an IDE and compile stand point, if you notice any problems please don't hesitate to re open this ticket and let me know! Thanks again for the suggestion!

(Typings should be available in the v3.0.0 release which I just published)

hisham commented 5 years ago

Thanks, it's confirmed working for me. ᐧ

On Fri, Nov 16, 2018 at 12:05 PM Dustin Hershman notifications@github.com wrote:

Closed #3 https://github.com/dhershman1/phone-fns/issues/3.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dhershman1/phone-fns/issues/3#event-1972010932, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE_vcDbdiNAH0wlti5Rh20VX3s2Cwt7ks5uvwyPgaJpZM4YetKX .