Shouldn't `await using` early throw for non-disposable objects?
Closed this issue · 2 comments
PaperStrike commented
In #180, the [Symbol.dispose]
method is wrapped when hint is 'async-dispose', even if the method is undefined
. This bypasses the outer check in CreateDisposableResource, where it would typically trigger a TypeError for undefined
method. I find this behavior unexpected, as the original issue #179 did not intend to alter the behavior of await using
/ AsyncDisposableStack.use
in a way that it would no longer throw errors for non-disposable values before usage but only when disposing.
rbuckton commented
I misspoke, you are correct that GetMethod will return undefined
when the function is null or undefined, which is not the intent of that change. Thank you for pointing out the discrepancy.