Home:ALL Converter>Is there any advantage of using declaration files over sources in typescript?

Is there any advantage of using declaration files over sources in typescript?

Ask Time:2020-02-02T01:25:07         Author:Luis Vargas

Json Formatter

When creating and publishing a library using typescript there are 2 options:

  1. Generate declaration files d.ts together with the bundled javascript file and then in package.json point to it with:

    "types": "./dist/mylib.d.ts"

  2. 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?

Author:Luis Vargas,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60019347/is-there-any-advantage-of-using-declaration-files-over-sources-in-typescript
yy