【问题标题】:ESLint error for ElementRef<any> and EmbeddedViewRef<any>ElementRef<any> 和 EmbeddedViewRef<any> 的 ESLint 错误
【发布时间】:2022-01-11 19:23:16
【问题描述】:

我已将我的 Angular 项目移至 ESLint 并修复了除 ElementRef&lt;any&gt;EmbeddedViewRef&lt;any&gt; 之外的所有 linting 错误。

错误: Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

谁能帮助我了解我应该在这些位置输入什么来代替任何内容?

const element = this.refElement.nativeElement.querySelector('.custom-filter-control');
element.appendChild((this.CUSTOMComponentRef.hostView as EmbeddedViewRef<any>).rootNodes[0]);
templateRef: TemplateRef<any>

【问题讨论】:

    标签: angular typescript eslint typescript-eslint


    【解决方案1】:

    这是关于它所指的元素的类型。例如,如果它是一个输入,您想使用 HTMLInputElement。对于所有类型,您可能需要检查它们here

    而对于模板,您需要提供模板上下文,这意味着模板中可以访问哪些变量。更详细的解释可以参考here

    【讨论】:

      猜你喜欢
      • 2021-06-21
      • 2023-04-05
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 2021-07-27
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      相关资源
      最近更新 更多