#11383·vitest

`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:

typescript
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:

json
{
  "compilerOptions": {
    "noUncheckedIndexedAccess": true
  }
}

System Info

bash
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.2

Used Package Manager

pnpm

Validations