-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Rule proposal: explicit-resource-management-literal-pair-using-dispose #7160
Comments
Thanks for the suggestion! That being said - TBH I think it's a bit early on in the proposal's lifecycle to be writing or proposing lint rules for it - given this is brand new syntax I think we should wait a few months for people to play around and use the feature to figure out the footguns and lint cases. Based on my limited understanding of the feature - I don't think that you will want to always function returnsDisposable(): Disposable {
const inner = { [Symbol.dispose]: () => {} };
return inner;
}
using outer = returnsDisposable(); In this instance you 100% wouldn't want to have This is why I think we need to wait some time before people sus out the patterns and pitfalls of the feature. |
Description updated in #7160 (comment) |
There's lots of potential footguns with const x = {[Symbol.dispose]() {}};
using one = x;
using two = x;
using three = one; This code is valid and at the end It's so hard to know exactly how people will want to use this feature and what the lint cases will be overall. I suspect a lot of these lint rules will probably not require types and will be able to live in eslint core as well. We'll have to wait and see! |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
When RHS literal object have literal property
Symbol.dispose
, LHS should haveusing
When LHS have
using
, RHS should be literal object with literal propertySymbol.dispose
Fail Cases
Pass Cases
Additional Info
https://github.com/tc39/proposal-explicit-resource-management
https://devblogs.microsoft.com/typescript/announcing-typescript-5-2-beta/#using-declarations-and-explicit-resource-management
microsoft/TypeScript#54505
evanw/esbuild#3191
The text was updated successfully, but these errors were encountered: