angular 的 tslint 问题 - 所有导入均未使用

tslint issue with angular - All imports are unused

我正在重构我的应用程序并解决 ts lint 提出的问题。

我能够解决大部分问题,但以下两个问题仍未解决。

ERROR:

view.component.ts[1, 61]: 'OnInit' is declared but never used.
done.component.ts[3, 1]: All imports are unused.

如果你真的看一下这两个组件的代码,

view.component.ts

export class ViewComponent implements OnInit  {

ngOnInit(): void {
    const ticketId = 123;
}

实际使用过

当第二个显示时,

done.component.ts

import { Component } from '@angular/core';
import { BaseComponent } from '../../../base.component';

@Component({
    selector: 'done',
    templateUrl: 'done.component.html'
})

export class DoneComponent extends BaseComponent {
}

这里是 ts-lint 配置。

两个进口都用过。同样,它显示许多 angular 方法未使用。这是 tslint 的常见问题吗?如果不是,如何解决?

问题是因为 no-unused-variable 尝试(删除它/创建它 false )并重新编译您的代码:

变化:

no-unused-variable : true,

收件人:

no-unused-variable : false,

Disallows unused imports, variables, functions and private class members. Similar to tsc’s –noUnusedParameters and –noUnusedLocals options, but does not interrupt code compilation.

有关详细信息,请查看 Link : https://github.com/palantir/tslint/issues/1481