36

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

the example is:

npm install --save @types/lodash

My question is whether --save-dev should be used in an application, because TypeScript is transpiled and not deployed? Some comments on the article mention similar, but there is no answer I could see.

Perhaps --save is useful in a library to drag around the types when others install your library?

Am I missing something else this is useful for and what is the best practice? Thanks.

4

1 回答 1

38

来自Microsoft/types-publisher #81

在编写简单的应用程序时使用 --save-dev 很好,它不会用作库。当您可能有依赖关系时,问题就会出现。如果您将类型声明存储在您的 devDependencies 中,您的消费者将不会自动获取您的类型声明。然后,他们必须手动将您的声明文件依赖项添加为他们的 devDependencies。

鉴于破坏消费者比稍微大一点的包更严重,我们在文档中设置了 --save 默认值。

于 2016-11-15T02:03:24.403 回答