From 1d606f664914480b5a28dd2246d5140729639776 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 24 Jul 2023 14:24:30 -0400 Subject: [PATCH] Allow functions as values in __addDisposableResource (#215) --- tslib.es6.js | 2 +- tslib.es6.mjs | 2 +- tslib.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index 801630c..270cc22 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -294,7 +294,7 @@ export function __classPrivateFieldIn(state, receiver) { export function __addDisposableResource(env, value, async) { if (value !== null && value !== void 0) { - if (typeof value !== "object") throw new TypeError("Object expected."); + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); var dispose; if (async) { if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); diff --git a/tslib.es6.mjs b/tslib.es6.mjs index 3f941d2..c8e2999 100644 --- a/tslib.es6.mjs +++ b/tslib.es6.mjs @@ -294,7 +294,7 @@ export function __classPrivateFieldIn(state, receiver) { export function __addDisposableResource(env, value, async) { if (value !== null && value !== void 0) { - if (typeof value !== "object") throw new TypeError("Object expected."); + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); var dispose; if (async) { if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); diff --git a/tslib.js b/tslib.js index 54c30ed..343ecde 100644 --- a/tslib.js +++ b/tslib.js @@ -342,7 +342,7 @@ var __disposeResources; __addDisposableResource = function (env, value, async) { if (value !== null && value !== void 0) { - if (typeof value !== "object") throw new TypeError("Object expected."); + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); var dispose; if (async) { if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");