diff --git a/packages/base/src/utils.ts b/packages/base/src/utils.ts index 3467fc7179..3fdd2e6d74 100644 --- a/packages/base/src/utils.ts +++ b/packages/base/src/utils.ts @@ -57,10 +57,10 @@ export type Dict = { [keys: string]: T }; * Returns a single Promise. */ export function resolvePromisesDict( - d: Dict> + d: Dict | V> ): Promise> { const keys = Object.keys(d); - const values: PromiseLike[] = []; + const values: (PromiseLike | V)[] = []; keys.forEach(function (key) { values.push(d[key]); }); diff --git a/packages/base/src/widget.ts b/packages/base/src/widget.ts index 5e942c8ff0..a56f470ea8 100644 --- a/packages/base/src/widget.ts +++ b/packages/base/src/widget.ts @@ -25,7 +25,7 @@ import { IClassicComm, ICallbacks } from './services-shim'; import { JUPYTER_WIDGETS_VERSION } from './version'; -import { Dict } from './utils'; +import { BufferJSON, Dict } from './utils'; import { KernelMessage } from '@jupyterlab/services'; @@ -227,7 +227,7 @@ export class WidgetModel extends Backbone.Model { case 'echo_update': this.state_change = this.state_change .then(() => { - const state = data.state; + const state: Dict = data.state; const buffer_paths = data.buffer_paths ?? []; const buffers = msg.buffers?.slice(0, buffer_paths.length) ?? []; utils.put_buffers(state, buffer_paths, buffers); @@ -651,11 +651,11 @@ export class WidgetModel extends Backbone.Model { * deserialization of widget models. */ static _deserialize_state( - state: JSONObject, + state: Dict, manager: IWidgetManager - ): Promise> { + ): Promise> { const serializers = this.serializers; - let deserialized: Dict; + let deserialized: Dict | BufferJSON>; if (serializers) { deserialized = {}; for (const k in state) {