catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.76k stars 218 forks source link

ts(1479) error in index.d.cts #446

Closed hfhchan-plb closed 1 year ago

hfhchan-plb commented 1 year ago

The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./types.d.js")' call instead. ts(1479)

A previous commit https://github.com/catamphetamine/libphonenumber-js/commit/55409b3dc37a018f556ec305b48d2e81dc2807a5 fixed the ts(1479) error when importing libphonenumber-js, but an error remains inside index.d.cts because ./types.d.js does not have a ./types.d.cjs equivalent.

catamphetamine commented 1 year ago

Hi. You're saying that "an error remains" but can you prove it with a screenshot of an actual error message or stack trace?

Also, the original merge request was created by @josh- so you could consult him for any further questions. I personally am not using TypeScript.

hfhchan-plb commented 1 year ago
image

So besides {index,metadata*,examples*}.d.ts, types.d.ts also needs to be cloned to types.d.cts as well, and all references in the *.d.cts files now need to reference types.d.cts instead of types.d.ts.

catamphetamine commented 1 year ago

I see. Ok. Published libphonenumber-js@1.10.42.