Closed andrewsantarin closed 3 years ago
Hi @andrewsantarin! Thanks for opening an issue! Adding type definitions to make TS usage easier definitely makes sense! It looks like you have the definitions all set up already, would you like to open up a PR for it? I think the suggestion you outlined makes a ton of sense.
@mcataford Cool! Allow me to whip one up. You'll be seeing that PR within a day or two.
Awesome! Looking forward to it!
:tada: This issue has been resolved in version 8.1.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I use
react-intl-tel-input
for a variety of projects over the past 3 years but recently, I've includedtypescript
because the latest project I'm working on is quite big. I want to have a reasonable amount of strictly-typed control over my components which this library doesn't have at the time of writing.Expected Behavior
This library should already have type definitions out of the box.
Current Behavior
Without any type definitions, the TypeScript compiler will complain. You need to get definitions from DefinitelyTyped (which doesn't exist yet) or declare the types yourself in every new project you write (inconvenient, of course).
Possible Solution
I've written drop-in support that you can check out in this gist. It was built to match the prop types of 7.x, but I imagine that 8.x hasn't changed anything, so those type definitions wouldn't be far off from the real thing:
https://github.com/patw0929/react-intl-tel-input/blob/d769a1e9a8b5b921b1f9bef74e8b6e75ceea7d73/src/components/IntlTelInput.js#L1324-L1401
If there are more modules exported by this library, then we should write type definitions for them, too, for full support.
Steps to Reproduce
Code:
Live Example: https://codesandbox.io/s/serene-leakey-b8uph
This is with the type definitions applied. To simulate what it looks like without type definitions, simply remove
index.d.ts
in the example.Environment
Detailed Description