From b331f811c1bde2a6d85cb80c8949767ffe5a00a7 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 9 Jun 2022 15:55:54 -0700 Subject: [PATCH] Add `thisArg` to `DataTransfer.forEach` (#151658) Fixes #151657 All of our other `forEach` functions take a `this` arg which is used when invoking the callback. This just aligns `DataTransfer.forEach` --- src/vs/workbench/api/common/extHostTypes.ts | 4 ++-- src/vscode-dts/vscode.d.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index e9a1b02b9f6..59d96e58586 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -2473,9 +2473,9 @@ export class DataTransfer { this.#items.set(mimeType, [value]); } - forEach(callbackfn: (value: DataTransferItem, key: string) => void): void { + forEach(callbackfn: (value: DataTransferItem, key: string) => void, thisArg?: unknown): void { for (const [mime, items] of this.#items) { - items.forEach(item => callbackfn(item, mime)); + items.forEach(item => callbackfn(item, mime), thisArg); } } } diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 88f7fdf67eb..730f0ad2014 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -10110,9 +10110,11 @@ declare module 'vscode' { /** * Allows iteration through the data transfer items. + * * @param callbackfn Callback for iteration through the data transfer items. + * @param thisArg The `this` context used when invoking the handler function. */ - forEach(callbackfn: (value: DataTransferItem, key: string) => void): void; + forEach(callbackfn: (value: DataTransferItem, key: string) => void, thisArg?: unknown): void; } /**