简体   繁体   English

TSLint 和 VSCode 未在 .ts 文件中显示红线

[英]TSLint and VSCode not showing red-line in .ts file

I have a single .ts file where i am learning to configure tslint and tsconfig.我有一个.ts文件,我正在学习配置 tslint 和 tsconfig。 I have induced extra spaces and removed semi-colon intentionally to check if tslint is configured properly.我引入了额外的空格并有意删除了分号以检查 tslint 是否配置正确。

Using command tslint filename.ts i could see tslint could find errors in .ts file but VSCode is not showing those red lines ?使用命令tslint filename.ts我可以看到 tslint 可以在 .ts 文件中找到错误,但 VSCode 没有显示那些red lines

I have generated tslint.json and tsconfig.json using CLI: tslint --init,tsc --init我已经使用 CLI 生成了 tslint.json 和 tsconfig.json: tslint --init,tsc --init

无红线

But in angular-app it shows但在 angular-app 中它显示

红线

What am i missing?我错过了什么? I went to through tslint and tsconfig docs, couldn't find how to configure.我浏览了 tslint 和 tsconfig 文档,找不到如何配置。

how to get red-line in normal ts-files?如何在普通的 ts 文件中获得红线? Thanks in advance提前致谢

Finally found the solution.终于找到了解决办法。 Its basically TSLint extension issue not TSLint CLI itself.它基本上是 TSLint 扩展问题而不是 TSLint CLI 本身。 The extension need tslint and typescript in node_modules for it to work.扩展need tslinttypescript在node_modules为它工作。 So i added package.json所以我添加了package.json

{
  "devDependencies": {
    "typescript": "^3.2.1",
    "tslint": "5.11.0"
  }
}

and ran npm install .并运行npm install Restarted VSCode.重新启动 VSCode。 I got those red-lines back.我拿回了那些红线。 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM