-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add [Symbol.dispose] alias to Disposable class #1203
Comments
While the general ideas are related, it's not clear to me that (in practice) this would actually help much. In particular, In general, |
Sure, and yeah we have a lot of Disposables that live a long time. it('should do stuff', () => {
using injector = createInjector();
const item = injector.get(UnitUnderTest);
// test
}); vs. it('should do stuff', () => {
const injector = createInjector();
const item = injector.get(UnitUnderTest);
// test
injector.dispose();
}); It would also be convenient in occasional functions that create short lived versions of classes that are disposable, just to do some processing, get a result, and return the result. function f() {
using someDisposable = new SomeDisposable();
return someDisposable.someComputation();
} vs. function f() {
const someDisposable = new SomeDisposable();
const result = someDisposable.someComputation();
someDisposable.dispose();
return result;
} Neither of these cases actually need the |
Thanks for those use cases. Presumably Closure Compiler will want to transpile |
With explicit resource management being added to the language in the near future (supported in TypeScript 5.2), it would be nice to be able to use the
using
keyword with closure-library Disposables.I think this would be as simple as this change:
I can make this change (with some actual comments) if no one objects.
The text was updated successfully, but these errors were encountered: