14

Should typescript declaration in package.json go in "dependencies", "devDependencies" or both? Based on some basic googling, I think I've seen references to putting the typescript declaration in either location. Does the package.json structure support a shared section for scenarios where the declaration should go in both "dependencies" and "devDependencies"? Or, if a developer sees a need for both scenarios then is he simply required to replicate the declaration in both locations?

6
  • Does someone need TS to use your library, or just to develop on it? Are your releases going to be packaged JS with an index file for use if they are using TS?
    – jonrsharpe
    Jul 20, 2017 at 16:29
  • TypeScript is not special. The answer to where to put it is exactly the same as any other NPM package you use, and the reason you found packages that included it in dependencies and some that included in devDependencies is because it entirely depends on what kind of package you are building.
    – Louis
    Jul 20, 2017 at 16:34
  • typescript provides a programming language that runs on top of javascript. I would need typescript installed in order to get typescript development features while developing in visual studio. I would think that some type of typescript suppport would be needed for deployed typescript apps as well, at least in some scenarios. so is this a scenario where the typescript declaration should be duplicated in both "dependencies" as well as "devDependencies"? Jul 20, 2017 at 16:40
  • 11
    Normally typescript files get compiled into javascript, and the javascript gets deployed. If that's the case, typescript is not needed at runtime. Jul 20, 2017 at 19:07
  • 1

1 Answer 1

-6

In the dependencies you should keep those libraries which are common at the runtime.

In the devDependencies you should keep those which are needed to build the project.

Not the answer you're looking for? Browse other questions tagged or ask your own question.