TSLint:警告:'no-use-before-declare' 规则需要类型检查
TSLint: Warning: The 'no-use-before-declare' rule requires type checking
我正在开发一个使用 TSLint 的中型 Angular 4 项目。
每次我 运行 使用 npm run lint
的 lint 命令(使用 ng lint
)时,我都会在命令行中看到警告:
Warning: The 'no-use-before-declare' rule requires type checking
我尝试通过添加 --type-check
和 --project path/to/the/tsconfig.json
文件来启用类型检查,这显然是“你需要做的一切”™ ,但无论我做什么,警告仍然显示在控制台中(好像标志没有任何效果)。
项目中没有 lint 问题,无论我是否使用 --type-check
和 --project
标志。
是否启用了类型检查?警告应该消失吗?
编辑
问题在于将标志从命令行传递到 ng lint
命令:
如果我运行命令行上的命令是这样的:
npm run lint --type-check --project tsconfig.json
然后我仍然在命令行上看到警告。如果我将 package.json 中的命令更新为:
"lint": "ng lint --type-check --project tsconfig.json",
然后控制台中 未显示 警告消息,我得到了一些额外的 lints。
问题仅在于将标志从命令行传递到 ng lint
命令。我从命令行使用此命令修复了它:
npm run lint -- --type-check
只需要额外的 --
来正确传递标志
此答案的快速更新:
TSlint 现在输出
--type-check is deprecated. You only need --project to enable rules which need type information.
使用 --type-check.
时
我正在开发一个使用 TSLint 的中型 Angular 4 项目。
每次我 运行 使用 npm run lint
的 lint 命令(使用 ng lint
)时,我都会在命令行中看到警告:
Warning: The 'no-use-before-declare' rule requires type checking
我尝试通过添加 --type-check
和 --project path/to/the/tsconfig.json
文件来启用类型检查,这显然是“你需要做的一切”™ ,但无论我做什么,警告仍然显示在控制台中(好像标志没有任何效果)。
项目中没有 lint 问题,无论我是否使用 --type-check
和 --project
标志。
是否启用了类型检查?警告应该消失吗?
编辑
问题在于将标志从命令行传递到 ng lint
命令:
如果我运行命令行上的命令是这样的:
npm run lint --type-check --project tsconfig.json
然后我仍然在命令行上看到警告。如果我将 package.json 中的命令更新为:
"lint": "ng lint --type-check --project tsconfig.json",
然后控制台中 未显示 警告消息,我得到了一些额外的 lints。
问题仅在于将标志从命令行传递到 ng lint
命令。我从命令行使用此命令修复了它:
npm run lint -- --type-check
只需要额外的 --
来正确传递标志
此答案的快速更新:
TSlint 现在输出
--type-check is deprecated. You only need --project to enable rules which need type information.
使用 --type-check.