Tuple of assertion parts to be converted to function parameter types
This type works recursively through the parts tuple, transforming each part
according to its type. The resulting tuple maintains the same structure as
the input but with user-facing TypeScript
types instead of internal
assertion part types.
// Given parts: ['to be a', z.string()]
// Results in: ['to be a' | 'not to be a', string]
type Slots = MapExpectSlots<['to be a', z.string()]>;
// Usage: expect(value, 'to be a', 'hello') or expect(value, 'not to be a', 'hello')
Maps
AssertionParts
to the corresponding argument types forexpect
andexpectAsync
functions.This utility type transforms assertion parts into the actual parameter types that users provide when calling expect functions. It handles both phrase literals and Zod schemas, creating appropriate
TypeScript
types for each slot.For phrase literals, it creates union types that include both the original phrase and its negated version (with
"not "
prefix). For Zod schemas, it extracts the inferred type. This enables natural language assertions with optional negation support.