The readonly tuple type to make flexible
type FlexibleArgs = MutableOrReadonly<readonly [string, number]>;
// Results in: [string, number] | readonly [string, number]
function acceptArgs(args: FlexibleArgs) { ... }
acceptArgs(['hello', 42]); // ✓ mutable array
acceptArgs(['hello', 42] as const); // ✓ readonly array
ExpectFunction and ExpectAsyncFunction which use this for parameter flexibility
Makes tuple types accept both mutable and readonly variants.
This utility type creates a union of both mutable and readonly versions of a tuple type, providing flexibility for function parameters that should accept either variant. This is particularly useful for assertion function parameters where users may pass either
const
arrays (readonly) or regular arrays.The type handles both array types and specific tuple types, creating appropriate unions for each case to maintain type safety while maximizing usability.