[英]How to fix Typescript linting not working in VSCode?
In my settings.json, I have:在我的 settings.json 中,我有:
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
Yet my typescript support isn't working.但是我的打字稿支持不起作用。 It catches the errors during runtime but doesn't show a red squiggly line (example below).它在运行时捕获错误,但不显示红色波浪线(下面的示例)。
I also get an error when enabling ESLint and Prettier doesn't work when I enable ESLint:启用 ESLint 时我也收到错误,启用 ESLint 时 Prettier 不起作用:
ESLint: Failed to load parser '@typescript-eslint/parser' declared in 'template/.eslintrc.js': Cannot find module 'typescript' Require stack: - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/typescript-estree/dist/parser.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/typescript-estree/dist/index.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/parser/dist/parser.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/@typescript-eslint/parser/dist/index.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/config-array-factory.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/cli-engine.js - /Users/henryboisdequin/Desktop/MyAwesomeProject/node_modules/eslint/lib/cli-engine/index.j
How do I fix this problem?我该如何解决这个问题?
The way to fix this problem is to follow these steps:解决此问题的方法是按照以下步骤操作:
Close VSCode关闭 VSCode
CD into applications光盘进入应用程序
/Users/<user>/Library/Application\ Support
ls
rm -rf code/ or .vscode/
Open up VSCode - there should be all your extensions there but stuff like your theme, extension settings will not be configured -打开 VSCode - 那里应该有你所有的扩展,但是像你的主题这样的东西,扩展设置不会被配置 -
Now everything (extension settings, theme, etc) will be reset现在一切(扩展设置、主题等)都将被重置
You can follow the steps to fix typescript您可以按照以下步骤修复打字稿
You can also try checking the TypeScript server logs to see why TSLint is not working:您还可以尝试检查 TypeScript 服务器日志以了解 TSLint 不工作的原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.