仅在 node_modules 中跳过库检查 [英] skip library check only in node_modules
问题描述
关于在错误输入的 node_modules
中禁用错误有几个问题(例如,这个,或这个),但它们都涉及使用skipLibCheck
编译器标志.
There are several questions about disabling errors in mistyped node_modules
(e.g., this one, or this one), but they all involve using the skipLibCheck
compiler flag.
是否有其他解决方案可以解决此问题(例如,使用 include
或 exclude
)?我有几个手写的 .d.ts
文件(比 absoluteTyped 上可用的类型更严格),我想对它们进行类型检查,因此对这些文件全面禁用类型检查并不吸引人.
Are there other solutions to this problem (e.g., using include
or exclude
)? I have a couple of hand-written .d.ts
files (stricter types than available on DefinitelyTyped) that I'd like to type check, so the wholesale disabling of typechecking on these files is not appealing.
推荐答案
没有对类型检查的精细控制,您要么检查所有声明文件,要么不幸的是不检查.来自编译器代码:
There is no granular control over type checking, you either check all declaration files or none unfortunately. From compiler code:
export function skipTypeChecking(sourceFile: SourceFile, options: CompilerOptions) {
// If skipLibCheck is enabled, skip reporting errors if file is a declaration file.
// If skipDefaultLibCheck is enabled, skip reporting errors if file contains a
// '/// <reference no-default-lib="true"/>' directive.
return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib;
}
这篇关于仅在 node_modules 中跳过库检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!