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

来源:2-6 Vite 中使用 Typescript

精慕门6455323

2021-07-17

// 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 }
           ~
写回答

2回答

Jokcy

2021-07-17

0
0

Jokcy

2021-07-17

是vue3的项目?

0
2
Jokcy
回复
精慕门6455323
理论上不应该去校验node_modules里面的定义,你可以加一下skipLibCheck
2021-07-20
共2条回复

Vite 从入门到精通,玩转新时代前端构建法则

从使用到原理到实战的【前端构建】高效学习路线,一次性掌握Vite

788 学习 · 104 问题

查看课程