From 9e4daf6069543e429e3d4b7088b973349d8f39cd Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 3 Jan 2019 16:21:41 -0800 Subject: [PATCH] Prefer using explicit function types instead of `Function` --- src/vs/base/browser/htmlContentRenderer.ts | 2 +- src/vs/base/common/async.ts | 2 +- src/vs/base/common/collections.ts | 2 +- src/vs/base/common/event.ts | 2 +- src/vs/base/common/worker/simpleWorker.ts | 4 ++-- src/vs/editor/common/services/webWorker.ts | 6 +++--- src/vs/editor/contrib/rename/renameInputField.ts | 6 ++---- src/vs/workbench/api/electron-browser/mainThreadProgress.ts | 2 +- src/vs/workbench/api/node/extHostTypes.ts | 4 ++-- src/vs/workbench/services/search/node/fileSearch.ts | 2 +- 10 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/vs/base/browser/htmlContentRenderer.ts b/src/vs/base/browser/htmlContentRenderer.ts index fd81c880241..cee63325b9b 100644 --- a/src/vs/base/browser/htmlContentRenderer.ts +++ b/src/vs/base/browser/htmlContentRenderer.ts @@ -92,7 +92,7 @@ export function renderMarkdown(markdown: IMarkdownString, options: RenderOptions // signal to code-block render that the // element has been created - let signalInnerHTML: Function; + let signalInnerHTML: () => void; const withInnerHTML = new Promise(c => signalInnerHTML = c); const renderer = new marked.Renderer(); diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index ace08b77709..edc2ad5e2db 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -318,7 +318,7 @@ export function timeout(millis: number, token?: CancellationToken): CancelablePr }); } -export function disposableTimeout(handler: Function, timeout = 0): IDisposable { +export function disposableTimeout(handler: () => void, timeout = 0): IDisposable { const timer = setTimeout(handler, timeout); return { dispose() { diff --git a/src/vs/base/common/collections.ts b/src/vs/base/common/collections.ts index ca40515c99c..f5c5cf5408b 100644 --- a/src/vs/base/common/collections.ts +++ b/src/vs/base/common/collections.ts @@ -58,7 +58,7 @@ export function first(from: IStringDictionary | INumberDictionary): T | * Iterates over each entry in the provided set. The iterator allows * to remove elements and will stop when the callback returns {{false}}. */ -export function forEach(from: IStringDictionary | INumberDictionary, callback: (entry: { key: any; value: T; }, remove: Function) => any): void { +export function forEach(from: IStringDictionary | INumberDictionary, callback: (entry: { key: any; value: T; }, remove: () => void) => any): void { for (let key in from) { if (hasOwnProperty.call(from, key)) { const result = callback({ key: key, value: (from as any)[key] }, function () { diff --git a/src/vs/base/common/event.ts b/src/vs/base/common/event.ts index f6b794079cf..493f02d1415 100644 --- a/src/vs/base/common/event.ts +++ b/src/vs/base/common/event.ts @@ -732,7 +732,7 @@ export class EventBufferer { } bufferEvents(fn: () => R): R { - const buffer: Function[] = []; + const buffer: Array<() => R> = []; this.buffers.push(buffer); const r = fn(); this.buffers.pop(); diff --git a/src/vs/base/common/worker/simpleWorker.ts b/src/vs/base/common/worker/simpleWorker.ts index 08531cd3459..3bb968d34f5 100644 --- a/src/vs/base/common/worker/simpleWorker.ts +++ b/src/vs/base/common/worker/simpleWorker.ts @@ -245,11 +245,11 @@ export class SimpleWorkerClient extends Disposable { }); // Create proxy to loaded code - let proxyMethodRequest = (method: string, args: any[]): Promise => { + const proxyMethodRequest = (method: string, args: any[]): Promise => { return this._request(method, args); }; - let createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise): Function => { + const createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise): () => Promise => { return function () { let args = Array.prototype.slice.call(arguments, 0); return proxyMethodRequest(method, args); diff --git a/src/vs/editor/common/services/webWorker.ts b/src/vs/editor/common/services/webWorker.ts index 07035be7f57..95539535e3a 100644 --- a/src/vs/editor/common/services/webWorker.ts +++ b/src/vs/editor/common/services/webWorker.ts @@ -69,13 +69,13 @@ class MonacoWebWorkerImpl extends EditorWorkerClient implements MonacoWebWork return proxy.loadForeignModule(this._foreignModuleId, this._foreignModuleCreateData).then((foreignMethods) => { this._foreignModuleCreateData = null; - let proxyMethodRequest = (method: string, args: any[]): Promise => { + const proxyMethodRequest = (method: string, args: any[]): Promise => { return proxy.fmr(method, args); }; - let createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise): Function => { + const createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise): () => Promise => { return function () { - let args = Array.prototype.slice.call(arguments, 0); + const args = Array.prototype.slice.call(arguments, 0); return proxyMethodRequest(method, args); }; }; diff --git a/src/vs/editor/contrib/rename/renameInputField.ts b/src/vs/editor/contrib/rename/renameInputField.ts index 5c60267db08..881417ed27f 100644 --- a/src/vs/editor/contrib/rename/renameInputField.ts +++ b/src/vs/editor/contrib/rename/renameInputField.ts @@ -128,10 +128,8 @@ export default class RenameInputField implements IContentWidget, IDisposable { this._inputField.setAttribute('selectionEnd', selectionEnd.toString()); this._inputField.size = Math.max((where.endColumn - where.startColumn) * 1.1, 20); - let disposeOnDone: IDisposable[] = [], - always: Function; - - always = () => { + const disposeOnDone: IDisposable[] = []; + const always = () => { dispose(disposeOnDone); this._hide(); }; diff --git a/src/vs/workbench/api/electron-browser/mainThreadProgress.ts b/src/vs/workbench/api/electron-browser/mainThreadProgress.ts index 3ce2237f606..83ef37518c2 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadProgress.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadProgress.ts @@ -11,7 +11,7 @@ import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostC export class MainThreadProgress implements MainThreadProgressShape { private _progressService: IProgressService2; - private _progress = new Map }>(); + private _progress = new Map void, progress: IProgress }>(); private _proxy: ExtHostProgressShape; constructor( diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 7c17d8d7ce1..9f7d7eb99f2 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -32,9 +32,9 @@ export class Disposable { }); } - private _callOnDispose?: Function; + private _callOnDispose?: () => any; - constructor(callOnDispose: Function) { + constructor(callOnDispose: () => any) { this._callOnDispose = callOnDispose; } diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 9b56487c323..4554f18097d 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -176,7 +176,7 @@ export class FileWalker { }); } - private call(fun: Function, that: any, ...args: any[]): void { + private call(fun: F, that: any, ...args: any[]): void { try { fun.apply(that, args); } catch (e) {