目前我不使用TypeScript,仅使用带有Babel的ES6。
我没有在node_modules中安装TypeScript。
每次打开工作区时,我都会收到来自VSCode的特定警告。
\node_modules\typescript\lib
没有指向有效的tsserver安装。 回到捆绑的TypeScript版本。
我该如何摆脱这些警告?或者我应该更改编辑器以感到放心?
目前我不使用TypeScript,仅使用带有Babel的ES6。
我没有在node_modules中安装TypeScript。
每次打开工作区时,我都会收到来自VSCode的特定警告。
\node_modules\typescript\lib
没有指向有效的tsserver安装。 回到捆绑的TypeScript版本。
我该如何摆脱这些警告?或者我应该更改编辑器以感到放心?
在 VS Code 中,可以通过这两个设置关闭 TypeScript 和 JavaScript 验证:
"typescript.validate.enable": false,
"javascript.validate.enable": false,
根据这里的说明,现在你可以在VSCode中禁用内置扩展。在左侧的扩展选项卡中(Ctrl+Shift+X),搜索@builtin
+JavaScript
/TypeScript
,然后点击一个扩展旁边的小齿轮图标,再点击禁用
。
我禁用了TypeScript和JavaScript语言特性
(有JavaScript语言基础
扩展)以及TypeScript语言基础
。
我遇到了类似的问题。我的用户设置中typescript.tsdk
的设置不正确:
"typescript.tsdk": null
要解决此问题,您可以将位置设置为有效的位置:
"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib",
如果您没有使用Typescript,可以从设置中删除该行。
如果您需要更多详细信息,请查看VSCode文档,其非常简明易懂。
在我的情况下,这是因为有一个使用了 vscode.typescript-language-features
扩展的扩展程序引起的。
我仍然希望显示 JavaScript 错误,所以 "javascript.validate.enable": false,
不是一个选项。
通过禁用使用了 @builtin 扩展的 "VueDX" 扩展程序,解决了该问题并仍然显示 JavaScript 语法错误。
您可以通过搜索 @builtin typescript
来查找所有 TypeScript 扩展程序。
Use the
// @ts-nocheck
comment to disable type checking for an entire file in TypeScript....
// @ts-nocheck console.log('no errors' / 0); console.log('no errors' / 0);
而TypeScript文档中提供的(它展示了如何变得更加细致):
You can skip checking some files by adding a
// @ts-nocheck
comment to files.TypeScript may offer you errors which you disagree with, in those cases you can ignore errors on specific lines by adding
// @ts-ignore
or// @ts-expect-error
on the preceding line.
// @ts-check /** @type {number} */ var x; x = 0; // OK // @ts-expect-error x = false; // Not OK
// eslint-disable-line
。vscode在保存时会删除该行。我已经安装了eslint和eslint vscode扩展程序,但没有安装tslint扩展程序。我的用户设置:"eslint.codeActionsOnSave.mode": "all", "breadcrumbs.enabled": true, "javascript.validate.enable": false, "typescript.validate.enable": false, "javascript.format.enable": false, "typescript.format.enable": false, "javascript.implicitProjectConfig.checkJs": false, "javascript.suggestionActions.enabled": false,
请帮忙! - barakbd