mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
`using` and `await using` now accept object literals and other values typed Disposable, AsyncDisposable or unknown. The declaration reads the value's [Symbol.dispose] method ([Symbol.asyncDispose] first for `await using`) and throws Node's TypeErrors for values that are not objects and for missing or non-callable methods; null and undefined dispose nothing. Scope exit calls the method with the value as `this`, and `await using` awaits the result of an async method but not of the sync fallback. A class instance reached through such a value throws an SC2020 error, because its dynamic view has no methods. SuppressedError is its own error class: a failing disposal over a pending error throws one whose `error` is the disposal error and whose `suppressed` is the pending error, both non-enumerable as in Node. `new SuppressedError(error, suppressed, message?)` and `instanceof SuppressedError` compile, and `extends SuppressedError` is refused.