Problem
StepContext.onTeardown is typed (fn: () => void | Promise<void>) => void. The natural cleanup one-liner doesn't typecheck:
ctx.onTeardown(() => Promise.all(people.map((p) => deletePerson(p.id))))
// ^ Type 'Promise<void[]>' is not assignable to 'void | Promise<void>'
So you have to wrap it just to discard the resolved array:
ctx.onTeardown(async () => {
await Promise.all(people.map((p) => deletePerson(p.id)))
})
Suggested direction
Widen the callback return type to () => unknown | Promise<unknown> (the result is awaited and discarded anyway). Same papercut applies anywhere a teardown thunk is accepted. Tiny DX win — Promise.all(...) and other value-returning cleanups just work.
Minor follow-up to #8.
Problem
StepContext.onTeardownis typed(fn: () => void | Promise<void>) => void. The natural cleanup one-liner doesn't typecheck:So you have to wrap it just to discard the resolved array:
Suggested direction
Widen the callback return type to
() => unknown | Promise<unknown>(the result is awaited and discarded anyway). Same papercut applies anywhere a teardown thunk is accepted. Tiny DX win —Promise.all(...)and other value-returning cleanups just work.Minor follow-up to #8.