tsconfig.vitest.json 如何正确配置?-灵析社区

兰豆儿

![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/2a38fc64c0268ef6e65e5bf56773cef8.png) ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250103/1dc3ba870004c1ef98fae4e3368cd681.png) "dependencies": { "@types/three": "^0.154.0", "pinia": "^2.0.28", "vue": "^3.2.45", "vue-axios": "^3.5.2", "vue-router": "^4.1.6" }, "devDependencies": { "@rushstack/eslint-patch": "^1.1.4", "@types/jsdom": "^20.0.1", "@types/node": "^18.11.12", "@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue-jsx": "^3.0.0", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^11.0.3", "@vue/test-utils": "^2.4.1", "@vue/tsconfig": "^0.4.0", "eslint": "^8.22.0", "eslint-plugin-vue": "^9.3.0", "jsdom": "^20.0.3", "less": "^4.1.3", "less-loader": "^11.1.0", "npm-run-all": "^4.1.5", "prettier": "^2.7.1", "terser": "^5.20.0", "typescript": "~5.2.2", "unplugin-vue-components": "^0.25.2", "vite": "^4.4.9", "vitest": "^0.25.6", "vue-tsc": "^1.8.10" } node v16.19.0 vscode 最新的 默认是没有设置 `module` 的; 我是希望解决 `import.meta` 的警告,来设置 `module` 的。 那么,现在应该如何做呢? * * * { "module": "ESNext", "moduleResolution": "node", } 似乎应当这样,但会不会有什么副作用?

阅读量:288

点赞量:17

问AI
«"https://www.typescriptlang.org/docs/handbook/module-> resolutio..." (https://link.segmentfault.com/?enc=UP3%2BNSmzBApqO%2BVKdaqDNQ%3D%3D.1H0YLjo5jd5xxQiaOnLlhZudYEvPLs8Fp0q6O09hClRfzVBRuG71BHlGDUGTGtCsrZRVnfRMaVmk%2BcqqJAI30hJbeKh0CbKdZUKlHyM5G2ac0PygTURpvXjmL36FmqBt%2F8NoKyP3zt0XIrqWfO529A%3D%3D)Note: "node" module resolution is the most-commonly used in the TypeScript community and is recommended for most projects. If you are having resolution problems with "imports" and "exports" in TypeScript, try setting "moduleResolution: "node"" to see if it fixes the issue.» 这个值是决定如何解析模块的,对于普通的导入导出没什么影响,但一旦你导入的包的 "package.json" 有 "exports" 这个字段的设置,就会有一些奇怪的表现。 一般来说不需要特殊设置,沿用默认值就可以了(默认值是什么由 Node 版本、TS 版本和 "module" 参数设定综合决定)。 TS v5.x 之后的话这个值建议设置成 "bundler",这也是默认值。 但说实话,无论设置成哪个值,我都没有复现出来题主截图中的错误(会有其他错误)。如果题主能提供一下环境信息(Node 版本、TS 版本、VSCode 版本、Vite 版本等等)是最好的了。