【发布时间】:2021-08-24 08:10:05
【问题描述】:
我目前已经开始使用 Typescript,并且已经使用了几天,一切正常(Emmet、linting 等),但是当我打开用 JavaScript 编写的旧项目时,vs 代码是给我关于打字和打字稿相关内容的警告和错误。 不知何故,Vs Code 无法识别我正在使用 JavaScript。
PS。我正在开发一个 vue (nuxt) 项目,而 Vetur 插件正在处理语法高亮、linting 等...
错误示例: 'modifyHtml' 已声明,但它的值永远不会被读取。ts(6133)
类型“CombinedVueInstance
这是我的 settings.js:
{
"workbench.iconTheme": "material-icon-theme",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"liveServer.settings.donotShowInfoMsg": true,
"editor.linkedEditing": true,
"liveServer.settings.donotVerifyTags": true,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"eslint.format.enable": true,
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"vue-css": "css",
"razor": "html",
"plaintext": "jade"
},
"emmet.excludeLanguages": ["markdown"],
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"git.confirmSync": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"nativescript.analytics.enabled": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.configuration.checkProjectSettingsExclusions": false,
"sonarlint.rules": {
"java:S106": {
"level": "off"
},
"javascript:S1117": {
"level": "off"
}
},
"workbench.preferredDarkColorTheme": "GitHub Dark",
"workbench.preferredHighContrastColorTheme": "GitHub Dark",
"workbench.preferredLightColorTheme": "Visual Studio Dark",
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"files.autoSave": "afterDelay",
"typescript.updateImportsOnFileMove.enabled": "always",
"vetur.experimental.templateInterpolationService": true,
"cSpell.userWords": ["vuex"],
"workbench.colorTheme": "GitHub Dark",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-expand-multiline"
},
"prettyhtml": {
"printWidth": 100,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
}
},
"files.associations": {
"*.vue": "vue"
},
"eslint.validate": ["javascript", "javascriptreact", "vue"],
"vetur.grammar.customBlocks": {
"docs": "md",
"i18n": "json"
},
"window.zoomLevel": -1,
"json.schemas": []
}
【问题讨论】:
-
你在为你的旧 Vue 项目使用 SFC 吗?
-
你能给我们看看你的 VScode 的截图吗?
-
@kissu 刚刚上传了一张截图
-
这是 Vetur 产生的错误,你应该禁用 Vetur 选项中的 TS 选项。有一个用于模板,另一个用于脚本,你不应该再有这些错误了。
-
感谢@ZakariaSahmane,它解决了问题...
标签: javascript typescript vue.js nuxt.js vetur