react-layout-transition icon indicating copy to clipboard operation
react-layout-transition copied to clipboard

Expose TS typings

Open TedDriggs opened this issue 6 years ago • 3 comments

Since the repo is written in TypeScript, having a separately-maintained @types package seems unnecessary. Would it be possible to export the type declarations as part of the built package?

TedDriggs avatar Jan 03 '18 17:01 TedDriggs

I'm trying to do this myself, and I've gotten hung up by the fact that it creates 3 different build outputs. I was hoping I could make a PR for it, but I may need @bkazi's help.

TedDriggs avatar Jan 03 '18 18:01 TedDriggs

The 3 build outputs are to accommodate different module types The output in dist folder is UMD primarily for direct imports on the web using script tags The output in lib folder is CommonJS format which uses the require syntax and output in es folder is ESModule format which uses the import syntax

I believe currently the easiest way to export type declarations would be using the typescript compilers --declarations flag which creates the .d.ts files needed. If there's a way to create these files and put them in a typings folder and publish to npm they should be used by typescript. Hope that helps!

bkazi avatar Jan 03 '18 19:01 bkazi

@bkazi that's possible, but then library consumers would have to manually add the types, and the maintainer of the type library would have to publish updates each time the package changes. I think the included approach would produce an easier experience, and should be only a couple lines in tsconfig.json (see these docs)

TedDriggs avatar Jan 03 '18 20:01 TedDriggs