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.77k stars 217 forks source link

Create type definitions(custom.d.ts) for custom.js #220

Closed asaarnak closed 6 years ago

asaarnak commented 6 years ago

Removed invalid type definitions from index.d.ts.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling c68c6c43c49012ae843c150b3964be171fc4bb6e on asaarnak:master into 98b6331f70f0b240ae33c9bf2d069a1a11bca332 on catamphetamine:master.

asaarnak commented 6 years ago

Created this PR because current *Custom() method typings give runtime error that method is missing. These index.js *Custom() methods are now in custom.js file. See: https://github.com/catamphetamine/libphonenumber-js/blob/master/custom.js

atsu85 commented 6 years ago

@asaarnak, looks like ES6 version re-exports stuff from custom.js - @catamphetamine, perhaps index.common.js should also reexport stuff from custom.js instead of changing type definitions with this PR?

catamphetamine commented 6 years ago

Thanks. Released libphonenumber-js@1.2.15.

atsu85 commented 6 years ago

@catamphetamine, I guess You didn't notice my comment/question - perhaps this should have been solved differently? I'm just suspecting that the approach of current PR might break things for es6 distribution users

catamphetamine commented 6 years ago

@atsu85 Oh, there's a comment there... I didn't see it.

looks like ES6 version re-exports stuff from custom.js - @catamphetamine, perhaps index.common.js should also reexport stuff from custom.js instead of changing type definitions with this PR?

The thing with ES6 is that it supports "tree shaking" (in theory, but most likely it currently doesn't work in Webpack). So one can export everything in a single ES6 file and the resulting bundle would still only include those functions which are being exported. Common.js doesn't support "tree shaking" so custom and non-custom functions must reside in separate files.

atsu85 commented 6 years ago

ok, thanks for giving a thought on in