From cf7c2aca66dc5c94c3b415ece305f4de525f1632 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 27 Jan 2021 16:07:09 +0100 Subject: [PATCH] More typings --- packages/voila/src/manager.ts | 15 ++++++++++----- packages/voila/src/utils.ts | 6 +++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/voila/src/manager.ts b/packages/voila/src/manager.ts index c4cf620ff..127b7d047 100644 --- a/packages/voila/src/manager.ts +++ b/packages/voila/src/manager.ts @@ -125,7 +125,11 @@ export class WidgetManager extends JupyterLabManager { return view.pWidget; } - async loadClass(className, moduleName, moduleVersion) { + async loadClass( + className: string, + moduleName: string, + moduleVersion: string + ): Promise { if ( moduleName === '@jupyter-widgets/base' || moduleName === '@jupyter-widgets/controls' || @@ -151,8 +155,7 @@ export class WidgetManager extends JupyterLabManager { } } - // eslint-disable-next-line @typescript-eslint/no-empty-function - restoreWidgets(notebook): Promise { + restoreWidgets(notebook: INotebookModel): Promise { return Promise.resolve(); } @@ -174,7 +177,7 @@ export class WidgetManager extends JupyterLabManager { }); } - async _build_models() { + async _build_models(): Promise<{ [key: string]: base.WidgetModel }> { const comm_ids = await this._get_comm_info(); const models = {}; /** @@ -215,7 +218,9 @@ export class WidgetManager extends JupyterLabManager { return models; } - async _update_comm(comm) { + async _update_comm( + comm: base.IClassicComm + ): Promise<{ comm: base.IClassicComm; msg: any }> { return new Promise((resolve, reject) => { comm.on_msg(async msg => { if (msg.content.data.buffer_paths) { diff --git a/packages/voila/src/utils.ts b/packages/voila/src/utils.ts index 9adf7430e..bb01d19cf 100644 --- a/packages/voila/src/utils.ts +++ b/packages/voila/src/utils.ts @@ -7,7 +7,11 @@ const delay = sec => new Promise(resolve => setTimeout(resolve, sec * 1000)); * and 'room' number of parallel calls. * Note that the minimum window at which rate is respected is room/rate seconds. */ -export const batchRateMap = (list, fn, { room, rate }) => { +export const batchRateMap = ( + list: string[], + fn: (...args: any[]) => Promise, + { room, rate }: { room: number; rate: number } +): Promise[] => { const limit = pLimit(room); return list.map(async value => { return new Promise((valueResolve, reject) => {