简体   繁体   English

VSCode TypeScript lint

[英]VSCode TypeScript lint

People, who develop TypeScript used Visual Studio Code? 开发TypeScript的人使用Visual Studio Code? I'm trying to use it too. 我也试着用它。 But I have no validation(ts-lint) warnings or errors. 但我没有验证(ts-lint)警告或错误。 I just got such messages on build: 我刚刚在构建时得到了这样的消息:

ts-lint start
src/constants/type.ts[22, 2]: file should end with a newline
src/constants/type.ts[6, 5]: misplaced opening brace
ts-lint end

Example: 例:

1 == 2

Such expression in JS file will message me that it will be better to use 1 === 2 . JS文件中的这种表达式会告诉我最好使用1 === 2 But this expression in TS file will work and not even show any warning. 但是TS文件中的这个表达式可以工作,甚至不会显示任何警告。

What can I do to enable such validation in TypeScript, while typing? 在键入时,我可以做什么来在TypeScript中启用此类验证?

Just had the exact same problem and seem to have resolved by adding "typescript" to the eslint.validate array in workspace settings 刚刚遇到完全相同的问题,似乎已通过在工作区设置中将“typescript”添加到eslint.validate数组来解决

{
 "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript"
    ]
}

Should you be new to VSCode. 你应该是VSCode的新手。 F1 => type "settings" => from the dropdown select either "user settings" (any project for that logged in user) or "workspace settings" (that one project only) => paste the above object on the right pane (or extend the existing object should there be one) F1 =>键入“settings”=>从下拉列表中选择“用户设置”(用户登录的任何项目)或“工作区设置”(仅限一个项目)=>将上述对象粘贴到右侧窗格(或扩展现有对象应该有一个)

Please update to 0.8.0 version of vs code, just released. 请更新到刚刚发布的vs代码的0.8.0版本。 JavaScript Linting as you Type is now supported. 现在支持您输入的JavaScript Linting。 https://code.visualstudio.com/updates https://code.visualstudio.com/updates

I did some experimentation running into a similar problem and found that I had a jsconfig.json file laying around that was created prior to converting code over to TypeScript. 我做了一些实验遇到了类似的问题,发现我有一个jsconfig.json文件,它是在将代码转换为TypeScript之前创建的。 After removing/renaming that file and restarting VSCode it appears that my TypeScript compiler errors are now showing up as the error output when doing a build in VSCode as opposed to seemingly unrelated errors about unresolved imports. 删除/重命名该文件并重新启动VSCode后,在VSCode中进行构建时,我的TypeScript编译器错误现在显示为错误输出,而不是看似无关的未解决的导入错误。

I'm not sure if this is the same problem you're experiencing but hopefully it's of some help to you or somebody else. 我不确定这是否与您遇到的问题相同,但希望这对您或其他人有所帮助。

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

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