Skip to content

Commit 2d9f0a9

Browse files
authored
Merge pull request #3554 from vidartf/use-buffer-json
Tweak some typings
2 parents 74774da + 84bf538 commit 2d9f0a9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/base/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ export type Dict<T> = { [keys: string]: T };
5757
* Returns a single Promise.
5858
*/
5959
export function resolvePromisesDict<V>(
60-
d: Dict<PromiseLike<V>>
60+
d: Dict<PromiseLike<V> | V>
6161
): Promise<Dict<V>> {
6262
const keys = Object.keys(d);
63-
const values: PromiseLike<V>[] = [];
63+
const values: (PromiseLike<V> | V)[] = [];
6464
keys.forEach(function (key) {
6565
values.push(d[key]);
6666
});

packages/base/src/widget.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { IClassicComm, ICallbacks } from './services-shim';
2525

2626
import { JUPYTER_WIDGETS_VERSION } from './version';
2727

28-
import { Dict } from './utils';
28+
import { BufferJSON, Dict } from './utils';
2929

3030
import { KernelMessage } from '@jupyterlab/services';
3131

@@ -227,7 +227,7 @@ export class WidgetModel extends Backbone.Model {
227227
case 'echo_update':
228228
this.state_change = this.state_change
229229
.then(() => {
230-
const state = data.state;
230+
const state: Dict<BufferJSON> = data.state;
231231
const buffer_paths = data.buffer_paths ?? [];
232232
const buffers = msg.buffers?.slice(0, buffer_paths.length) ?? [];
233233
utils.put_buffers(state, buffer_paths, buffers);
@@ -651,11 +651,11 @@ export class WidgetModel extends Backbone.Model {
651651
* deserialization of widget models.
652652
*/
653653
static _deserialize_state(
654-
state: JSONObject,
654+
state: Dict<BufferJSON>,
655655
manager: IWidgetManager
656-
): Promise<utils.Dict<unknown>> {
656+
): Promise<utils.Dict<BufferJSON>> {
657657
const serializers = this.serializers;
658-
let deserialized: Dict<any>;
658+
let deserialized: Dict<PromiseLike<BufferJSON> | BufferJSON>;
659659
if (serializers) {
660660
deserialized = {};
661661
for (const k in state) {

0 commit comments

Comments
 (0)