Vite生成的React TS模板在VS Code报错但项目可正常运行求助
React + TypeScript 项目在VS Code中报错但可正常运行的问题
- 已尝试解决该问题长达一年,至今无果
- 通过
npm create vite@latest创建全新React + TypeScript模板项目,未做任何修改,但VS Code始终显示大量报错,项目却能正常运行(报错截图:
) - 使用
npx react-native init生成的代码也存在同样问题,该问题仅出现在TSX文件中,Elysia + Bun JS的TypeScript项目则表现正常 - 全局安装的TS版本为5.5.2,工作区版本为5.5.4,切换两个版本后问题仍未解决
我的VS Code settings.json配置
{ "tabnine.experimentalAutoImports": true, "files.autoSave": "afterDelay", "workbench.startupEditor": "none", "[python]": { "editor.formatOnType": true }, "explorer.confirmDelete": false, "javascript.updateImportsOnFileMove.enabled": "always", "git.mergeEditor": true, "merge-conflict.autoNavigateNextConflict.enabled": true, "git.confirmSync": false, "editor.minimap.enabled": false, "emmet.includeLanguages": { "javascript": "javascriptreact", "typescript": "typescriptreact" }, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.formatOnSave": true, "prettier.jsxSingleQuote": true, "prettier.useTabs": true, "prettier.trailingComma": "all", "workbench.iconTheme": "material-icon-theme", "editor.fontFamily": "'Cascadia Code', Consolas, 'Courier New', monospace", "editor.fontLigatures": true, "editor.inlineSuggest.enabled": true, "github.copilot.enable": { "*": true, "plaintext": true, "markdown": true, "scminput": false }, "workbench.editorAssociations": { "*.csv": "gc-excelviewer-csv-editor" }, "workbench.colorTheme": "Visual Studio Dark", "prettier.singleAttributePerLine": true, "prettier.singleQuote": true, "prettier.semi": false, "diffEditor.ignoreTrimWhitespace": true, "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/Current", "telemetry.telemetryLevel": "off", "peacock.favoriteColors": [ { "name": "Angular Red", "value": "#dd0531" }, { "name": "Azure Blue", "value": "#007fff" }, { "name": "JavaScript Yellow", "value": "#f9e64f" }, { "name": "Mandalorian Blue", "value": "#1857a4" }, { "name": "Node Green", "value": "#215732" }, { "name": "React Blue", "value": "#61dafb" }, { "name": "Something Different", "value": "#832561" }, { "name": "Svelte Orange", "value": "#ff3d00" }, { "name": "Vue Green", "value": "#42b883" } ], "typescript.updateImportsOnFileMove.enabled": "always", "workbench.productIconTheme": "fluent-icons", "window.zoomLevel": 1, "security.workspace.trust.untrustedFiles": "open", "github.copilot.editor.enableAutoCompletions": true, "update.showReleaseNotes": false, "typescript.disableAutomaticTypeAcquisition": true, "typescript.experimental.updateImportsOnPaste": true, "javascript.showUnused": false, }
内容的提问来源于stack exchange,提问作者Shiraku Yanai
相关产品推荐
相关产品推荐

