[英]tslint issue with angular - All imports are unused
I am doing some refactoring with my application and resolving issues raised by ts lint. 我正在对应用程序进行一些重构,以解决ts lint引发的问题。
I was able to resolve most of the issues but the following two issues remains unresolved. 我能够解决大多数问题,但以下两个问题仍未解决。
ERROR:
view.component.ts[1, 61]: 'OnInit' is declared but never used.
done.component.ts[3, 1]: All imports are unused.
if you really look at the code of both the components, 如果您真的看过两个组件的代码,
view.component.ts view.component.ts
export class ViewComponent implements OnInit {
ngOnInit(): void {
const ticketId = 123;
}
It has been actually used. 它已被实际使用。
while the 2nd one shows, 而第二个显示
done.component.ts 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 {
}
here is the ts-lint
config. 这是
ts-lint
配置。
both imports have been used. 两种进口均已使用。 Similarly it shows many angular methods as not used.
同样,它显示了许多未使用的角度方法。 is this a common issue with tslint?
这是tslint的常见问题吗? if not how can this be resolved?
如果没有,如何解决?
Issue is because of no-unused-variable
try to ( remove it / make it false
) and recompile your code: 问题是因为
no-unused-variable
尝试(将其删除/设为false
)并重新编译代码:
Change : 变更:
no-unused-variable : true,
To : 至 :
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.
与tsc的–noUnusedParameters和–noUnusedLocals选项相似,但不会中断代码编译。
For More Detail Please Go Through The Link : https://github.com/palantir/tslint/issues/1481 有关更多详细信息,请通过链接: https : //github.com/palantir/tslint/issues/1481
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.