Changes in new versions / TypeScript 5.2

// *** before: ***
function readFile(path: string) {
    const handle = openFile(path);
    try {
        return handle.read();
    } finally {
        handle.close(); // закрытие руками в try/finally на каждый ресурс
    }
}
declare function openFile(path: string): { read(): stringclose(): void };

// *** in version 5.2: ***
function readFileUsing(path: string) {
    using handle = openFileDisposable(path);
    return handle.read();
    // handle[Symbol.dispose]() вызовется автоматически при выходе из блока,
    // в том числе при исключении
}
declare function openFileDisposable(path: string): { read(): string } &
    Disposable;