using declarations and explicit resource management

Changes in new versions / TypeScript 5.2

// *** before: ***
function readFile(path: string) {
    const handle = openFile(path);
    try {
        return handle.read();
    } finally {
        handle.close(); // closed by hand in a try/finally for every resource
    }
}
declare function openFile(path: string): { read(): string; close(): void };

// *** in version 5.2: ***
function readFileUsing(path: string) {
    using handle = openFileDisposable(path);
    return handle.read();
    // handle[Symbol.dispose]() is called on the way out of the block,
    // an exception included
}
declare function openFileDisposable(path: string): { read(): string } &
    Disposable;