typescript - @typescript-eslint/no-unsafe-assignment - `any` 值的不安全分配
问题描述
我在我的 Angular 项目中使用应用洞察库。我使用 eslint 对代码进行 lint,这确实有助于发现一些奇怪的错误:
@Injectable({ providedIn: "root" })
export class AppInsightsService {
appInsights: ApplicationInsights;
constructor() {
this.appInsights = new ApplicationInsights({ // ====> HERE
config: {
instrumentationKey: environment.appInsights.instrumentationKey,
enableAutoRouteTracking: true
}
});
this.appInsights.loadAppInsights(); // ====> HERE
}
logPageView(name?: string, url?: string): void {
this.appInsights.trackPageView({ // ====> AND HERE
name,
uri: url
});
}
...
}
但是 lint 在我添加注释的行中显示以下错误:
值的不安全分配
any
.eslint@typescript-eslint/no-unsafe-assignment)
有人可以解释一下这个appInsights
领域有什么问题吗?
解决方案
推荐阅读
- c++ - 用“gcc -c”编译一个 C++ 程序顺利通过。为什么?
- javascript - Can't pass var (which is a function) as argument in another function
- r - 总结后变异 - dplyr
- c# - 强制主线程在 RunWorkerCompletedEventArgs 上使用 Return
- javascript - 发生鼠标悬停事件时如何更改绘图图上的光标?
- manifest - 显示:“独立”PWA 不删除地址栏
- encoding - GitKraken 文件编码
- teamcity - Teamcity 不运行整个自定义脚本
- jquery - 背景图像出现在链接悬停
- ios - 总结 Swift 中 UITextField 中的每个数字