如何为@ types / definition使用版本文件夹

时间:2017-03-29 08:29:21

标签: javascript typescript npm package.json definitelytyped

我想得到react-router的类型,但是当你在package.json中有这个依赖时:

{
  "@types/react-router": "^4.0.3"
}

它使用DefinitelyTyped库中的标准index.d.ts(对于react-router 1.0来说是正确的)。

我知道v2 and v3的DefinitelyTyped中有文件夹 - 我相信v3会有我想要的一切。

如何在项目中使用v3文件夹?

我是否必须手动输入文件夹中的打字,或者是否已经有自动方法?

1 个答案:

答案 0 :(得分:1)

在模块名称后使用@。例如,要安装@ types / react-router v3,请运行:

npm install @types/react-router@v3