Answer the question
In order to leave comments, you need to log in
How to create an npm package with typescript?
I already tried to create npm on typescript package but I still don't understand:
- Where to put typescript and javascript files?
Why do you need to create a folder dist
?
- Which file to specify in package.json
, .ts
or .js
?
- Do I need to create .d.ts
files?
- Add "type": "module"
to package.json
?
- Use export
or module.export
s?
- Is it necessary to create @types/проект
, and if so, what should be done there?
Answer the question
In order to leave comments, you need to log in
- Where to put typescript and javascript files?
Where is it convenient for you
- Why do you need to create a dist folder?
Usually you write your sources in TS. Therefore, you compile it to JS and publish the JS. Usually the compiled js is in the dist folder.
- Which file to specify in package.json, .ts or .js?
js.
- Do I need to create .d.ts files?
Yes
- Should I add "type": "module" to package.json?
- Use export or module.exports?
Depends on what format you compile your JS into
- Do I need to create an @types/project, and if so what should I do there?
No. This is only needed if your d.ts files are not included in the package itself.
And the internet is full of guides.
https://itnext.io/step-by-step-building-and-publis...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question