Skip to content

Vitest config benchmark.reporters has incorrect type; forbids passing arbitrary file paths #9692

@Bertie690

Description

@Bertie690

Describe the bug

Currently, benchmark.reporters has the type Arrayable<"default" | "verbose" | Reporter>, meaning the only strings it can accept without type errors are those of the built-in bench reporters.

This goes directly against its documentation ("... one or more built-in report names, reporter instances, and/or paths to custom reporters"1), as well as Vitest's runtime behavior of using the reporter as normal.

/**
* Custom reporter for output. Can contain one or more built-in report names, reporter instances,
* and/or paths to custom reporters
*
* @default ['default']
*/
reporters?: Arrayable<BenchmarkBuiltinReporters | Reporter>

A solution would be adding string & {} to the type signature; this would allow arbitrary strings while preserving IDE autocomplete for the default types.

Reproduction

TS Playground

System Info

N/A; occurs on latest version of vitest.

Used Package Manager

pnpm

Validations

Footnotes

  1. Bolded for emphasis

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions