From dd74ed19570f7091769d15f20e25957758e1a4b9 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 15 Nov 2021 13:08:32 +0530 Subject: [PATCH] Add types to disposeValue --- src/utils/Disposables.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/Disposables.ts b/src/utils/Disposables.ts index b63cba85..6b9200f0 100644 --- a/src/utils/Disposables.ts +++ b/src/utils/Disposables.ts @@ -14,7 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -function disposeValue(value) { +type func = () => void; +type Disposable = { dispose: func; [key: string]: any } | func; + +function disposeValue(value: Disposable): void { if (typeof value === "function") { value(); } else { @@ -27,9 +30,7 @@ function isDisposable(value) { } export class Disposables { - constructor() { - this._disposables = []; - } + private readonly _disposables = []; track(disposable) { if (!isDisposable(disposable)) {