![](/img/trans.png)
[英]VS Code - unable to hide javascript files generated from typescript files
[英]VS Code treats JavaScript files as Typescript
我目前已經開始使用 Typescript 並且我已經使用了幾天,一切正常(Emmet、linting 等),但是當我打開用 JavaScript 編寫的舊項目時,vs 代碼給了我警告以及有關與 typescript 相關的打字和內容的錯誤。 不知何故,Vs Code 無法識別我正在使用 JavaScript。
PS。 我正在開發一個 vue (nuxt) 項目,而 Vetur 插件正在處理語法高亮、linting 等...
錯誤示例:聲明了“modifyHtml”,但它的值從不讀取。ts(6133)
屬性 '$store' 不存在於類型“CombinedVueInstance<Record<never, any> & Vue, object, object, object, Record<never, any>>.
這是我的 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": []
}
如果您有 tslint,請嘗試禁用它。 這可能會解決問題,但有時這些錯誤也會出現在 eslint 中
這對我有用。 在我的工作區settings.json
:
{
"vetur.validation.interpolation": false
}
這是我的jsonfig.json
設置:
{
"include": ["./src/**/*"]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.