Type Alias: CleanupHandler()<Args>
ts
type CleanupHandler<Args> = (...args: Args) => void | Promise<void>;Shape of the cleanup handler function.
Cleanup handlers are returned by hook handlers to perform cleanup operations after the main action completes (successfully or with an error).
Type Parameters
| Type Parameter | Description |
|---|---|
Args extends any[] | The arguments passed to the cleanup handler (typically includes error and other context) |
Parameters
| Parameter | Type |
|---|---|
...args | Args |
Returns
void | Promise<void>
Example
ts
// Cleanup handler that removes a file on error
const cleanup: CleanupHandler<[Error | null]> = async (error) => {
if (error) {
await fs.unlink("./temp-file.txt");
}
};