Prefer using explicit function types instead of `Function`

pull/66115/head
Matt Bierner 2019-01-03 16:21:41 -08:00
parent 967eef771b
commit 9e4daf6069
10 changed files with 15 additions and 17 deletions

View File

@ -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();

View File

@ -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() {

View File

@ -58,7 +58,7 @@ export function first<T>(from: IStringDictionary<T> | INumberDictionary<T>): 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<T>(from: IStringDictionary<T> | INumberDictionary<T>, callback: (entry: { key: any; value: T; }, remove: Function) => any): void {
export function forEach<T>(from: IStringDictionary<T> | INumberDictionary<T>, 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 () {

View File

@ -732,7 +732,7 @@ export class EventBufferer {
}
bufferEvents<R = void>(fn: () => R): R {
const buffer: Function[] = [];
const buffer: Array<() => R> = [];
this.buffers.push(buffer);
const r = fn();
this.buffers.pop();

View File

@ -245,11 +245,11 @@ export class SimpleWorkerClient<T> extends Disposable {
});
// Create proxy to loaded code
let proxyMethodRequest = (method: string, args: any[]): Promise<any> => {
const proxyMethodRequest = (method: string, args: any[]): Promise<any> => {
return this._request(method, args);
};
let createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise<any>): Function => {
const createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise<any>): () => Promise<any> => {
return function () {
let args = Array.prototype.slice.call(arguments, 0);
return proxyMethodRequest(method, args);

View File

@ -69,13 +69,13 @@ class MonacoWebWorkerImpl<T> extends EditorWorkerClient implements MonacoWebWork
return proxy.loadForeignModule(this._foreignModuleId, this._foreignModuleCreateData).then((foreignMethods) => {
this._foreignModuleCreateData = null;
let proxyMethodRequest = (method: string, args: any[]): Promise<any> => {
const proxyMethodRequest = (method: string, args: any[]): Promise<any> => {
return proxy.fmr(method, args);
};
let createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise<any>): Function => {
const createProxyMethod = (method: string, proxyMethodRequest: (method: string, args: any[]) => Promise<any>): () => Promise<any> => {
return function () {
let args = Array.prototype.slice.call(arguments, 0);
const args = Array.prototype.slice.call(arguments, 0);
return proxyMethodRequest(method, args);
};
};

View File

@ -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();
};

View File

@ -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<number, { resolve: Function, progress: IProgress<IProgressStep> }>();
private _progress = new Map<number, { resolve: () => void, progress: IProgress<IProgressStep> }>();
private _proxy: ExtHostProgressShape;
constructor(

View File

@ -32,9 +32,9 @@ export class Disposable {
});
}
private _callOnDispose?: Function;
private _callOnDispose?: () => any;
constructor(callOnDispose: Function) {
constructor(callOnDispose: () => any) {
this._callOnDispose = callOnDispose;
}

View File

@ -176,7 +176,7 @@ export class FileWalker {
});
}
private call(fun: Function, that: any, ...args: any[]): void {
private call<F extends Function>(fun: F, that: any, ...args: any[]): void {
try {
fun.apply(that, args);
} catch (e) {