When creating and publishing a library using typescript there are 2 options:
Generate declaration files
d.ts
together with the bundled javascript file and then inpackage.json
point to it with:"types": "./dist/mylib.d.ts"
Don't generate the declaration files and point directly to the source code in
package.json
witt:"types": "./src/index.ts"
What is the adventage of each one?
I suggest the following strategy:
Library Package
In the library package, distribute only the complied JavaScript with the declarations files. This has the advantage of reducing the package size while giving developers the option to use your library with either JavaScript or TypeScript.
Code Repository
In the code repository for the library, only commit the source files - not the compiled JavaScript nor the declarations files. Put instructions for how to compile the library in your README, and perhaps also a script that will perform the compilation. This will allow other developers to change and use your library after any modifications they make.