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
Describe the bug
Currently,
benchmark.reportershas the typeArrayable<"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.
vitest/packages/vitest/src/node/types/benchmark.ts
Lines 27 to 33 in 4d7938a
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
Bolded for emphasis ↩