using in the upcoming typescript 5.2
In the upcoming TypeScript 5.2, it’s planed to add a very interesting and useful feature called using. Similar functionality already exists in other languages: in C# it’s using, and in Go it’s defer. The main idea is that using allows you to automatically release a resource (by calling a special method for this) after it exits the scope of the block. For example, if we have a method getResource that has implemented the method [Symbol.dispose](), then we can write the following code and the Symbol.dispose method will be executed automatically at the end of the main function, as if this construct were wrapped in a try finally block. ...