在已安装的依赖项中排除 @types 类型 [英] Exclude @types typings in installed dependencies

查看:37
本文介绍了在已安装的依赖项中排除 @types 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在已安装的依赖项中排除全局类型?

Is it possible to exclude global typings in installed dependencies?

我安装了本地依赖项.这也复制了该依赖项的 node_modules 文件夹.此 node_modules 文件夹包含已安装的 @types 类型.这些与为主项目安装的 @types 类型冲突.

I installed a local dependency. This also copied the node_modules folder of that dependency. This node_modules folder holds installed @types typings. These conflict with the @types typings installed for the main project.

例如.project-path/node_modules/local-dependency/node_modules/@types/reactproject-path/node_modules/@types/react 冲突.

是否可以让 typescript 编译器忽略该本地依赖项中的类型?

Is it possible to make the typescript compiler ignore the typings in that local dependency?

推荐答案

您是否尝试对 types 选项使用空数组?

Did you try to use an empty array for types option?

{
  "compilerOptions": {
    ...,
    "types": []
  }
}

这会禁用自动包含类型.

This disables automatic inclusion of types.

请参阅 TypeScript 文档了解更多详情.

See the TypeScript documentation for more details.

这篇关于在已安装的依赖项中排除 @types 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆