`test.for` doesn't type-check with `noUncheckedIndexedAccess` enabled
Author: jessestrickerCreated Sep 28, 2026Updated Sep 29, 2026
Labelspending triage
Describe the bug
When I enable noUncheckedIndexedAccess in a tsconfig.json, the tests no longer type-check when destructuring the params array in the test function, as all the parameters include undefined.
This does not happen with test.each, however.
Reproduction
srgb.test.ts:
describe("Srgb", () => {
test.for([
[0, 0, 0],
])("valid returns true when all components in 0..1", ([r, g, b]) => {
expect(new Srgb(r, g, b).valid).toBe(true);
// error on `r`:
// Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
// Type 'undefined' is not assignable to type 'number'.
});
});
describe("Srgb2", () => {
test.each([
[0, 0, 0],
])("valid returns true when all components in 0..1", (r, g, b) => {
expect(new Srgb(r, g, b).valid).toBe(true);
// no errors here
});
});tsconfig.json:
{
"compilerOptions": {
"noUncheckedIndexedAccess": true
}
}System Info
Binaries:
Node: 26.10.0 - /nix/store/x9iqbiwqaw81lvkpirikqm13cp6whn9s-nodejs-26.10.0/bin/node
npm: 11.19.1 - /nix/store/x9iqbiwqaw81lvkpirikqm13cp6whn9s-nodejs-26.10.0/bin/npm
pnpm: 11.27.0 - /nix/store/f6wrd19wh402lz5dqzg7y1m6kwnz554m-pnpm-11.27.0/bin/pnpm
npmPackages:
typescript: ^6.0.3 => 6.0.3
vitest: ^5.0.2 => 5.0.2Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Source: vitest-dev/vitest