paul-thebaud / v-phone-input

International and accessible phone input for Vuetify 3 and Vue 3.
https://paul-thebaud.github.io/v-phone-input/
MIT License
64 stars 6 forks source link

bug: wrong typings in package.json for TS 4.7+ #26

Closed azygis closed 9 months ago

azygis commented 9 months ago

package.json does not contain types definition in exports section, which is required with TS versions 4.7+. Fallback (the old types property directly in the file) works only as long as the exports property isn't yet handled by TS (which is <4.7). Currently, with TS 5.3 (most likely any version since 4.7) import fails with this:

Could not find a declaration file for module 'v-phone-input'. '/src/frontend/node_modules/v-phone-input/dist/v-phone-input.js' implicitly has an 'any' type.
  There are types at '/src/frontend/node_modules/v-phone-input/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'v-phone-input' library may need to update its package.json or typings.ts(7016)

It's enough to simply copy the types from root of the file and add it to exports section.

paul-thebaud commented 9 months ago

Hello @azygis, I'm not having this issue on other projects using TS 5+, so maybe the problem is related to something else? I'll take a look soon.

azygis commented 9 months ago

I'm not convinced myself that it's the only possible problem/solution. That's the first issue in this repo regarding such a problem - I would imagine someone to have already had this happen before me.

Sadly, I can't really find another way to fix it otherwise. By adding types to exports, it starts working fine.

For what is worth, I'm experiencing this both with TS 5.3.2 and 5.3.3. Sorry, cannot verify the other versions.

paul-thebaud commented 9 months ago

OK, I'll try this PR in a patch release soon and give feedback here! Stay tuned!

paul-thebaud commented 9 months ago

@azygis, fix release in v4.1.2 :tada: Working on my applications.