简体   繁体   中英

Bundle types with npm package from declaration files

I am trying to create my first npm module, here is the source code:

https://github.com/balazsorban44/use-form

I would like to use semantic-release and write my code in .js files, but I also include some type declaration files for a better experience in IDEs like VSCode. (Note, I am learning TypeScript as well)

I found a way to bundle my code and even publish it to npm with semantic-release, but when I try to import that module into a React project, I don't get any suggestions from the IDE, probably because I missed a (or a few) step(s)? How can I include the .d.ts files, so my IDE will pick up the type declarations?

I figured out, thanks to the help I got on Twitter!

In package.json I had to add my typings folder to the files to be published on NPM:

https://github.com/balazsorban44/use-form/blob/c4e7efdbb7ca58a3ad48516e3ec63b4a71b72446/package.json#L46-L49

Apart from that, these lines may play an important role also:

https://github.com/balazsorban44/use-form/blob/c4e7efdbb7ca58a3ad48516e3ec63b4a71b72446/package.json#L18-L20

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM