npm 或yarn 是否具有自动安装@types 的功能(如果它们存在于Typescript 项目中)?

Bat*_*rka 4 npm typescript yarnpkg

npm如果Typescript 项目中存在没有自己类型的包,是否yarn有自动安装的功能?@types/*

就像是:

//package.json
{
  // ...
  installTypes: true
}

// installing package
yarn add ABC <- will install ABC + @types/ABC
Run Code Online (Sandbox Code Playgroud)

And*_*ndy 6

https://www.npmjs.com/package/@yarnpkg/plugin-typescript有一个纱线 v2+ 插件

从yarn v4开始,默认包含它。

使用yarn v2或v3时的安装说明是:

yarn plugin import typescript
Run Code Online (Sandbox Code Playgroud)