简体   繁体   English

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

[英]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.

相关问题 如何配置tslint以检查Angular2中的未使用变量 - How to configure tslint to check no-unused-variable in Angular2 删除未使用的Angular模块依赖项(导入和提供程序) - Removing unused Angular module dependencies (imports and providers) Angular Firebase:导入问题 - Angular Firebase: issue with imports 离子3 - 所有进口都是未使用的警告(即使它们被使用) - Ionic 3 - All imports are unused warning (even though they are being used) 你能在用 typescript/angular 导出它之前创建一个 class 吗? | TSLint:未使用的表达式,需要赋值或 function 调用 - Can you create a class before exporting it in typescript/angular? | TSLint: unused expression, expected an assignment or function call 运行 tslint 时,角度单元测试中的“未使用的表达式,期望赋值或函数调用” - 'unused expression, expected an assignment or function call' in an angular unit test when running tslint 在有角度的应用程序中,TSLint能否通过相对路径通过路径映射iso强制执行模块导入? - In an angular app, can TSLint enforce module imports via path mapping iso via relative paths? Angular 2 - 共享文件中的所有导入 - Angular 2 - All imports in a shared files TypeScript/TSLint:TSLint 无法通过 baseUrl 识别相对于根目录的导入 - TypeScript/TSLint: TSLint not recognizing root-relative imports via baseUrl 修复Angular 6问题,未使用的类型和属性不存在 - Fix Angular 6 issue with unused type and property not existing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM