如何在节点模块软件包上跳过打字稿的noImplicitAny = true规则? [英] how to skip typescript's noImplicitAny=true rule on node modules packages?

查看:340
本文介绍了如何在节点模块软件包上跳过打字稿的noImplicitAny = true规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Typescript 2和Webpack 2构建angular 2应用程序.作为加载程序,我使用awesome-typescript-loader.我在tsconfig.json中设置了noImplicitAny = true.但是我隐式使用的某些npm软件包具有"any"类型. (例如angular2-platform-node).因此,我只想在npm软件包上跳过该规则,而不要在我的应用程序源上跳过该规则.我该如何配置?

I'm building angular 2 app using Typescript 2 and Webpack 2. As a loader I use awesome-typescript-loader. I set noImplicitAny = true in tsconfig.json. But some of npm packages I used implicitly has an 'any' type. (e.g. angular2-platform-node). So I want to skip that rule only on npm packages but not on my app source. How can I configure for that?

推荐答案

您可以使用skipLibCheck编译器选项(在打字稿2.0中添加)跳过对所有声明文件的类型检查

You can skip type checking for all declaration files with skipLibCheck compiler option (added in typescript 2.0)

{
  "compilerOptions": {
    "noImplicitAny": true,
    "skipLibCheck": true,
    ...
}

这篇关于如何在节点模块软件包上跳过打字稿的noImplicitAny = true规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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