请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

配置isolatedModules执行build指令,vue-runtime报错。

// tsconfig.json
{
    "compilerOptions": {
      "target": "esnext",
      "module": "esnext",
      "moduleResolution": "node",
      "strict": true,
      "jsx": "preserve",
      "sourceMap": true,
      "resolveJsonModule": true,
      "esModuleInterop": true,
      "lib": ["esnext", "dom"],
      "types": ["vite/client"],
      "isolatedModules": true
    },
    "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
  }
{
    "version": "0.0.0",
    "scripts": {
        "dev": "vite",
        "build": "vue-tsc --noEmit && tsc --noEmit && vite build",
        "serve": "vite preview"
    },
    "dependencies": {
        "@vitejs/plugin-vue-jsx": "^1.1.6",
        "less": "^4.1.1",
        "typescript": "^4.3.5",
        "vue": "^3.0.5",
        "vue-tsc": "^0.2.1"
    },
    "devDependencies": {
        "@postcss-plugins/console": "^0.2.5",
        "@types/vfile-message": "^2.0.0",
        "@vitejs/plugin-vue": "^1.2.5",
        "@vue/compiler-sfc": "^3.0.5",
        "vite": "^2.4.2"
    }
}

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1112:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1112     [BooleanFlags.shouldCast]?: boolean;
          ~~~~~~~~~~~~

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1113:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

1113     [BooleanFlags.shouldCastTrue]?: boolean;
          ~~~~~~~~~~~~

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1593:10 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is 
provided.

1593 export { TrackOpTypes }
              ~~~~~~~~~~~~

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1621:10 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is 
provided.

1621 export { TriggerOpTypes }
              ~~~~~~~~~~~~~~

src/test.ts:6:10 - error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

6 export { A }
           ~

正在回答 回答被采纳积分+3

2回答

Jokcy 2021-07-17 13:23:54
Jokcy 2021-07-17 13:23:43

是vue3的项目?

0 回复 有任何疑惑可以回复我~
  • 提问者 精慕门6455323 #1
    是的,我把vue-tsc --noEmit 去掉 就正常来。直接执行 tsc --noEmit && vite build就可以正常build了
    回复 有任何疑惑可以回复我~ 2021-07-17 15:33:35
  • Jokcy 回复 提问者 精慕门6455323 #2
    理论上不应该去校验node_modules里面的定义,你可以加一下skipLibCheck
    回复 有任何疑惑可以回复我~ 2021-07-20 20:16:52
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信