Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite fresh install: TypeScript error for vitest.config.ts #317

Closed
marvhock opened this issue Jul 22, 2023 · 1 comment
Closed

Vite fresh install: TypeScript error for vitest.config.ts #317

marvhock opened this issue Jul 22, 2023 · 1 comment

Comments

@marvhock
Copy link

marvhock commented Jul 22, 2023

See issue on Discord

Hi!

I just made a fresh install (vue@3.3.4, vite@4.4.6)npm init vue@latest.
Sadly I have a TS Error in vitest.config.ts:7

  viteConfig,
  defineConfig({
    test: {
      environment: 'jsdom',
      exclude: [...configDefaults.exclude, 'e2e/*'],
      root: fileURLToPath(new URL('./', import.meta.url)),
      transformMode: {
        web: [/\.[jt]sx$/]
      }
    }
  })
)

The Error says the following.
S2345: Argument of type 'UserConfigExport' is not assignable to parameter of type 'UserConfig | Promise'.   Type 'UserConfigFn' is not assignable to type 'UserConfig | Promise'.

Question:

  • Can I fix it, or is it only able inside the Vite Package itself? Is there an Update to fix that?
  • Is it bad to have a TS error (like that) on a fresh install. Should I worry about TS Errors or are they not important?

How to Reproduce

  1. Open Terminal on mac, run npm create vite@latest
  2. Follow the install instructions using: TS, TSX, VueRouter, Piania, Vitest, Cypress, ESlint, prettier
  3. run. cd && npm i && npm run format && npm run dev
  4. In Webstorm I get that error in the file after File-Indexing is finished in Webstorm
haoqunjiang added a commit to haoqunjiang/vitest that referenced this issue Jul 24, 2023
Ported from vitejs/vite#13792

Fully fixes issues like vuejs/create-vue#317
and vuejs/create-vue#313

For an easy reproduction, please refer to https://github.com/sodatea/viteste-define-config-bug-repro

I didn't include a test in this PR because:

1. The reproduction is a bit complicated, it only fails on the very
latest Vite versions, but updating Vite would mess up the lockfile.
2. By not updating the dependencies, we can make sure that this fix is
compatible with older versions of Vite, too.
@haoqunjiang
Copy link
Member

  • Can I fix it, or is it only able inside the Vite Package itself? Is there an Update to fix that?
  1. Update Vite to the latest version
  2. Then apply this patch: b948832
  • Is it bad to have a TS error (like that) on a fresh install. Should I worry about TS Errors or are they not important?

It's bad, but not that important. The code still runs despite the type issue.
The type-check command only checks src at the moment, as they are the most important ones.
That's also why we didn't catch the issue in our own tests.
(We are considering making it more comprehensive, though #274)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants