using disposes the resource when the block ends
Files, locks, database clients and timers all need a matching release, and a try/finally for each one is noise people forget to write. using calls Symbol.dispose when the scope ends.
{
using client = await pool.connect(); // client[Symbol.asyncDispose] releases it
await client.query("...");
}It needs TypeScript 5.2 or later, and await using handles async cleanup. Wrap third-party handles in a small object that implements the symbol, and the leaks stop.
typescript