gpt4 book ai didi

angular - 如何使用/声明一个外部模块,它不会在 Angular 11 中通过严格和 noImplicitReturns TypeScript 设置?

转载 作者:行者123 更新时间:2023-12-05 01:07:53 24 4
gpt4 key购买 nike

我们有一个带有 strict mode 的 Angular 11 应用程序打开。它在 tsconfig.jsoncompilerOptions 配置中有这些值:

"strict": true,
"noImplicitReturns": true,

现在我们要使用外部库 (leaflet geoman)。库是这样导入的:

import * as L from 'leaflet';
import '@geoman-io/leaflet-geoman-free';

不幸的是,它包括隐式 any 类型以及隐式 any 返回类型:

Parameter 'options' implicitly has an 'any' type.
'setLang', which lacks return-type annotation, implicitly has an 'any' return type

如何告诉编译器在编译期间忽略模块中的这些错误,但在项目的其余部分保持 strict 模式打开?

最佳答案

您可以调用 compiler 并使用 --skipLibCheck 标志来实现您想要的。

--skipLibCheckTypeScript 2.0 中添加:skiplibcheck

tsc --skipLibCheck

您可以在此线程中阅读有关为什么使用它的更多信息:

Usage of the TypeScript compiler argument 'skipLibCheck'

关于angular - 如何使用/声明一个外部模块,它不会在 Angular 11 中通过严格和 noImplicitReturns TypeScript 设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66817188/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com