interface ErrorConstructor { new (...args: T): Error; } export function ensure(condition: boolean, ErrorToThrow: ErrorConstructor, ...errorArgs: T): asserts condition { if (!condition) { throw new ErrorToThrow(...errorArgs); } }