使用 --save 或 --save-dev 保存 npm @types 类型

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

TypeScript 2 建议对类型使用 npm。在 The Future of Declaration Files.

例子是:

npm install --save @types/lodash

我的问题是 --save-dev 是否​​应该在应用程序中使用,因为 TypeScript 是转译而不是部署的?文章的一些评论提到类似的,但我没有看到答案。

也许 --save 在库中有用,可以在其他人安装您的库时拖动类型?

我是否遗漏了其他有用的东西?最佳做法是什么?谢谢

来自 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.