Option ‘importsNotUsedAsValues‘ has been removed. Please remove it from your configuration
1、背景
在前端项目中的tsconfig.json中 compilerOptions 报红,鼠标放上去,会显示如下内容:
Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration. Use 'verbatimModuleSyntax' instead.ts
Option 'preserveValueImports' has been removed. Please remove it from your configuration. Use 'verbatimModuleSyntax' instead.ts
Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
Visit https://aka.ms/ts6 for migration information.
2、原因
从上面可以看出,用的TypeScript版本较新,而项目中@vue/tsconfig中包含了一些已弃用或移除的编译器选项
{ "extends": "@vue/tsconfig/tsconfig.web.json", "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], "compilerOptions": { "paths": { "@/*": ["./src/*"] } }, "references": [ { "path": "./tsconfig.config.json" } ] }3、解决方案
看到版本问题,我直接就先更新 tsconfig
npm update @vue/tsconfig
更新后,发现还是报红
重启VS Code后发现正常了,已解决
