angular - 如何正确检查 typescript 应用程序中未使用的变量/参数

标签 angular typescript angular-cli tslint

我想检查 Angular2 应用中未使用的变量/参数,该应用由 Angular CLI 1.0.0-rc.1 生成。

1) 我为 TSLint 添加了 "no-unused-variable" 规则,但它说:

no-unused-variable is deprecated. Use the tsc compiler options --noUnusedParameters and --noUnusedLocals instead.

2) 我已将此选项添加到编译器,但某些第三方软件包出现新问题:

ERROR in .../node_modules/angular2-material-datepicker/src/datepicker.component.ts (3,43): 'state' is declared but never used.) .../node_modules/angular2-material-datepicker/src/datepicker.component.ts (312,23): Property 'renderer' is declared but never used.) .../node_modules/angular2-material-datepicker/src/datepicker.component.ts (386,20): 'day' is declared but never used.)

3) 我尝试以这种方式向 TS 配置文件添加排除选项:

{
  "compilerOptions": {
    ...
  },
  "exclude": [
    ...
    "node_modules"
  ]
}

但这并没有帮助,TS 编译器无论如何都会显示警告。

TS 编译器是否应该检查来自 node_modules 的包?

最佳答案

您可以使用--skipLibCheck 跳过对外部库的检查

关于angular - 如何正确检查 typescript 应用程序中未使用的变量/参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42696868/

相关文章:

typescript - TS4.1 : Is there a way to define this property path type that isn't excessively deep?

javascript - 为什么我的时间/日期选择器格式会增加分钟数?

javascript - Angular2 ElementRef nativeElement 检查元素是否被禁用

javascript - TypeScript 中是否可以有通用的装饰器,可以根据其输入/输出类型进行链接?

html - YouTube 缩略图破坏了 maxres 使用

angularjs - 无法使用 angular-cli 创建 Angular 5 项目

node.js - 在调试时拥有可用的第三方 JavaScript 库的源代码

javascript - Angular Material - sidenav 组件无法正常工作

angular - 如何从父组件查询 ng-content 的输入元素

javascript - 检查属性与检查函数返回值的性能如何?