Skip to content

The output of defineProject can't be used as an argument in mergeConfig #4316

@matchai

Description

@matchai

Describe the bug

Reproducing the configuration provided in the docs, TS surfaces a type error:

import { defineProject, mergeConfig } from 'vitest/config'
import configShared from '../vitest.shared.js'

export default mergeConfig(
  configShared,
  defineProject({  << Argument of type 'UserProjectConfigExport' is not assignable to parameter of type 'UserWorkspaceConfig | Promise<UserWorkspaceConfig>'.
    test: {
      environment: 'jsdom',
    }
  })
)

Reproduction

Reproduction with relevant TS error:
https://stackblitz.com/edit/vitest-dev-vitest-bfmggz?file=packages%2Fexample%2Fvitest.config.ts

System Info

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M2
    Memory: 496.63 MB / 24.00 GB
    Shell: 3.6.1 - /run/current-system/sw/bin/fish
  Binaries:
    Node: 20.7.0 - ~/Library/Caches/fnm_multishells/13490_1696999864522/bin/node
    npm: 10.1.0 - /opt/homebrew/bin/npm
    pnpm: 8.8.0 - ~/Library/pnpm/pnpm
    Watchman: 2023.08.14.00 - /Users/matchai/.nix-profile/bin/watchman
  Browsers:
    Brave Browser: 109.1.47.171
    Chrome: 118.0.5993.70
    Safari: 17.0
  npmPackages:
    @vitest/coverage-v8: ^0.34.6 => 0.34.6
    vitest: 1.0.0-beta.2 => 1.0.0-beta.2

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions