Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Expose TS typings #9

Open
TedDriggs opened this issue Jan 3, 2018 · 3 comments
Open

Expose TS typings #9

TedDriggs opened this issue Jan 3, 2018 · 3 comments

Comments

@TedDriggs
Copy link

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
Copy link
Author

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.

@bkazi
Copy link
Owner

bkazi commented Jan 3, 2018

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!

@TedDriggs
Copy link
Author

@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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants