omeralpi / shadcn-phone-input

Customizable phone input component with proper validation for any country. Built on top of shadcn.
https://shadcn-phone-input.vercel.app
MIT License
422 stars 28 forks source link

Fix: type 'string' is not assignable to type 'E164Number' #28 #35

Open aashishpanthi opened 2 months ago

aashishpanthi commented 2 months ago

It resolves the build error on your nextjs project caused by the type error. The complete error message is:

Types of property 'value' are incompatible. Type 'string' is not assignable to type 'E164Number'

Added some basic type conversion to resolve issue #28

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shadcn-phone-input ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2024 5:45pm
OliverCordingl1 commented 2 months ago

All works on my end

aashishpanthi commented 2 months ago

All works on my end

I think it only works on your end. You can see issue #28 lots of people are having the same problem.

OliverCordingl1 commented 2 months ago

All works on my end

I think it only works on your end. You can see issue #28 lots of people are having the same problem.

Sorry - I mean I tested the changes you made on mine and it fixed it with no other issues.

@omeralpi Can this be merged?

abeisleem commented 2 months ago

This is not working for me. It's incomplete from my end. I had to do the following changes to get it working.

This way the phone input is treated as a string and casting happening inside the PhoneInput without it being the developers concern.

image

abeisleem commented 2 months ago

But tbh, I don't like this approach to the solution and am curious that I didn't have this issue before I installed "libphonenumber-js": "^1.11.3". I imagine there's something else happening and this solution is a workaround.

omeralpi commented 2 months ago

I believe the issue has been resolved automatically since an issue was opened on the libphonenumberjs side. I am not encountering any errors at the moment.

See: GitLab - libphonenumber-js Issue 144

abeisleem commented 2 months ago

I tried upgrading and it's still erroring for me. Does your working setup include this PR or without it?

omeralpi commented 2 months ago

I tried upgrading and it's still erroring for me. Does your working setup include this PR or without it?

Can you delete the node_modules and package-lock.json files, then reinstall? Also, could you share your package.json file?