我的 Angular 项目(v13)的打字稿类上有以下代码片段:
import { Component } from '@angular/core';
import { MyService } from 'service';
@Component({
selector: 'app-example',
templateUrl: './example.component.html'
})
export class ExampleComponent {
constructor(
private myService: MyService
) {}
getUsers() {
this.myService.getUsers().subscribe(response => {
// do something;
})
}
}
Run Code Online (Sandbox Code Playgroud)
我使用 ESlint 版本 7.26.0 运行该项目并扩展了以下插件:
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"eslint:recommended"
Run Code Online (Sandbox Code Playgroud)
运行 ng lint 时遇到的 lint 错误是:
'mySerive' is defined but never used no-unused-vars
Run Code Online (Sandbox Code Playgroud)
显然,我的班级正在使用 myService。
这是预期的行为还是如何解决此问题?
PS:我不想禁用该规则。
我将 ESLint 与 Angular v13 结合使用。
我在使用时遇到以下 lint 错误// @ts-ignore
:
Do not use "// @ts-ignore" comments because they suppress compilation errors @typescript-eslint/ban-ts-ignore
Run Code Online (Sandbox Code Playgroud)
貌似@typescript-eslint
不建议使用@ts-ignore
。
有没有其他方法可以告诉 TypeScript 编译器忽略代码中的特定行?
我想使用ngx-translate库检测“当前语言”的切换。
我可以使用哪个 js 事件来实现这一点?
为了更好地理解我的意思,请检查这个简单的示例: https: //stackblitz.com/edit/github-yvbmgu
我想在 ngOnInit() 上检测“diff”组件中 currentLang 的变化。
typescript angular-components ngx-translate angular angular13