Describe the bug
If you have exactOptionalPropertyTypes enabled then various parts of vitest do not compile.
There are 249 errors inside the repo if you compile with it but what's more important is that it's observable for users.
I'd be happy to contribute these fixes but I want to know if I should limit to what users can observe (e.g. errors within the output .d.ts files) or fix it even within function bodies.
Reproduction
This is personally how I ran into it:
import type { VitestRunner } from "@vitest/runner"; // types: v4.0.14
import { VitestTestRunner } from "vitest/runners"; // types: v4.0.14
export default class Runner extends VitestTestRunner implements VitestRunner {}
// ^ Class 'Runner' incorrectly implements interface 'VitestRunner'.
// The types of 'config.name' are incompatible between these types.
// Type 'string | undefined' is not assignable to type 'string'.
// Type 'undefined' is not assignable to type 'string'.
https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true#code/JYWwDg9gTgLgBDAnmApnA3nAasGKDOMASgK4B2ZKUcAvnAGZQQhwBEAAgG64EwD0UcpSisA3HD58EyAgC44nACwA6AAzKAjIoBQoSLAzYehACq9SFKrQZMWrbnkIChVfGIlSkqfPKVrNOtooAB768AAmKPQAhiQANvAAxnHR+PhwFsJwIXhk4ek4jjBmhJlWenEoIChkMAXGxC7U6DTaknAdnV3dXQB6cADCKWlwAORlUKNwwGSJ0FAoiTBxiNPgldW16TN4UDGJaKOF5k2jym1SPVfXcCYAFmheBHAQ9GNzZPTAAObKZNHVKbRBbTWbMMDRGDAABGlTg0JQMAA7igaggHvhHjJ8Od2jd8d0TDIxoQoDNvnAAD5wciRL6UcJTYDpMgQeCpfA-f6wx4QaSoEkwMlkb5nC4EiVdIkC0a0qIzFCM6YstlwDlc6I8hB8p6C4Wi5RAA
System Info
System:
OS: Linux 6.6 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
CPU: (16) x64 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
Memory: 3.88 GB / 27.31 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 24.5.0 - /home/david/.nvm/versions/node/v24.5.0/bin/node
npm: 11.5.1 - /home/david/.nvm/versions/node/v24.5.0/bin/npm
bun: 1.2.4 - /home/david/.bun/bin/bun
Deno: 2.1.1 - /home/david/.deno/bin/deno
npmPackages:
@vitest/browser-playwright: ^4.0.13 => 4.0.13
@vitest/ui: ^4.0.13 => 4.0.13
vite: ^7.2.4 => 7.2.4
vitest: ^4.0.13 => 4.0.13
Used Package Manager
npm
Validations
Describe the bug
If you have
exactOptionalPropertyTypesenabled then various parts of vitest do not compile.There are 249 errors inside the repo if you compile with it but what's more important is that it's observable for users.
I'd be happy to contribute these fixes but I want to know if I should limit to what users can observe (e.g. errors within the output .d.ts files) or fix it even within function bodies.
Reproduction
This is personally how I ran into it:
https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true#code/JYWwDg9gTgLgBDAnmApnA3nAasGKDOMASgK4B2ZKUcAvnAGZQQhwBEAAgG64EwD0UcpSisA3HD58EyAgC44nACwA6AAzKAjIoBQoSLAzYehACq9SFKrQZMWrbnkIChVfGIlSkqfPKVrNOtooAB768AAmKPQAhiQANvAAxnHR+PhwFsJwIXhk4ek4jjBmhJlWenEoIChkMAXGxC7U6DTaknAdnV3dXQB6cADCKWlwAORlUKNwwGSJ0FAoiTBxiNPgldW16TN4UDGJaKOF5k2jym1SPVfXcCYAFmheBHAQ9GNzZPTAAObKZNHVKbRBbTWbMMDRGDAABGlTg0JQMAA7igaggHvhHjJ8Od2jd8d0TDIxoQoDNvnAAD5wciRL6UcJTYDpMgQeCpfA-f6wx4QaSoEkwMlkb5nC4EiVdIkC0a0qIzFCM6YstlwDlc6I8hB8p6C4Wi5RAA
System Info
System: OS: Linux 6.6 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat) CPU: (16) x64 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics Memory: 3.88 GB / 27.31 GB Container: Yes Shell: 5.2.21 - /bin/bash Binaries: Node: 24.5.0 - /home/david/.nvm/versions/node/v24.5.0/bin/node npm: 11.5.1 - /home/david/.nvm/versions/node/v24.5.0/bin/npm bun: 1.2.4 - /home/david/.bun/bin/bun Deno: 2.1.1 - /home/david/.deno/bin/deno npmPackages: @vitest/browser-playwright: ^4.0.13 => 4.0.13 @vitest/ui: ^4.0.13 => 4.0.13 vite: ^7.2.4 => 7.2.4 vitest: ^4.0.13 => 4.0.13Used Package Manager
npm
Validations