Saving npm @types typings with --save or --save-dev

后端 未结 1 1242
面向向阳花
面向向阳花 2021-01-07 17:05

TypeScript 2 recommends using npm for types. In The Future of Declaration Files.

the example is:

npm install --save @types/lodash

M

相关标签:
1条回答
  • 2021-01-07 17:25

    From Microsoft/types-publisher #81:

    Using --save-dev is fine when you're writing a simple application, and it won't be used as a library. The problem comes along when you might have dependencies. If you stored your type declarations in your devDependencies, your consumers would not automatically get your type declarations. They'd then have to manually add your declaration file dependencies as their devDependencies.

    Given that breaking consumers is a worse problem than slightly-larger packages, we've made --save the default in our documentation.

    0 讨论(0)
提交回复
热议问题