在我的settings.json中,我有:
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
但是我的打字稿支持不起作用。它会在运行时捕获错误,但不会显示红色的波浪线(下面的示例)。
启用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
如何解决此问题?
答案 0 :(得分:1)
您可以按照以下步骤修复打字稿
您还可以尝试检查TypeScript服务器日志以查看TSLint无法正常工作的原因:
答案 1 :(得分:0)
解决此问题的方法是按照以下步骤操作:
关闭VSCode
将CD放入应用程序
/Users/<user>/Library/Application\ Support
ls
rm -rf code/ or .vscode/
打开VSCode-应该在那里有所有扩展名,但是诸如主题,扩展名设置之类的东西不会配置-
现在所有内容(扩展设置,主题等)将被重置