Skip to content

Commit

Permalink
Merge pull request #3554 from vidartf/use-buffer-json
Browse files Browse the repository at this point in the history
Tweak some typings
  • Loading branch information
jasongrout authored Aug 26, 2022
2 parents 74774da + 84bf538 commit 2d9f0a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/base/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export type Dict<T> = { [keys: string]: T };
* Returns a single Promise.
*/
export function resolvePromisesDict<V>(
d: Dict<PromiseLike<V>>
d: Dict<PromiseLike<V> | V>
): Promise<Dict<V>> {
const keys = Object.keys(d);
const values: PromiseLike<V>[] = [];
const values: (PromiseLike<V> | V)[] = [];
keys.forEach(function (key) {
values.push(d[key]);
});
Expand Down
10 changes: 5 additions & 5 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<BufferJSON> = data.state;
const buffer_paths = data.buffer_paths ?? [];
const buffers = msg.buffers?.slice(0, buffer_paths.length) ?? [];
utils.put_buffers(state, buffer_paths, buffers);
Expand Down Expand Up @@ -651,11 +651,11 @@ export class WidgetModel extends Backbone.Model {
* deserialization of widget models.
*/
static _deserialize_state(
state: JSONObject,
state: Dict<BufferJSON>,
manager: IWidgetManager
): Promise<utils.Dict<unknown>> {
): Promise<utils.Dict<BufferJSON>> {
const serializers = this.serializers;
let deserialized: Dict<any>;
let deserialized: Dict<PromiseLike<BufferJSON> | BufferJSON>;
if (serializers) {
deserialized = {};
for (const k in state) {
Expand Down

0 comments on commit 2d9f0a9

Please sign in to comment.