【发布时间】:2022-12-13 08:19:10
【问题描述】:
我在 Typescript React 项目中使用 Vite。我的项目中也有开玩笑的测试。
当我运行vite build时,它似乎正在编译和捆绑我的测试文件。我有一些存根测试,我计划立即进行一些编译错误。
当我运行 yarn build 时的示例 tsc && vite build
> yarn build
yarn run v1.22.17
warning package.json: No license field
$ tsc && vite build
src/core/utils/numberUtils.spec.ts:1:1 - error TS1208: 'numberUtils.spec.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
1 describe('numberUtils - ', () => {
~~~~~~~~
Found 1 error.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
再仔细看一下,当我运行tsc 时,实际上是 Typescript 抛出了错误,尽管我仍然不确定 Vite 是否捆绑了它。
使用vite时如何修复tsc错误?
【问题讨论】:
-
多看一点,实际上是 Typescript 在我运行
tsc时抛出错误,尽管我仍然不确定 Vite 是否捆绑了它。 -
您找到问题的答案了吗?