Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refine IClassicCom types #3722

Merged
merged 3 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 20 additions & 19 deletions packages/base/src/services-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { Kernel, KernelMessage } from '@jupyterlab/services';
import type { JSONValue, JSONObject } from '@lumino/coreutils';

/**
* Callbacks for services shim comms.
Expand Down Expand Up @@ -40,9 +41,9 @@ export interface IClassicComm {
* @return msg id
*/
open(
data: any,
callbacks: any,
metadata?: any,
data: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string;

Expand All @@ -55,9 +56,9 @@ export interface IClassicComm {
* @return message id
*/
send(
data: any,
callbacks: any,
metadata?: any,
data: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string;

Expand All @@ -70,9 +71,9 @@ export interface IClassicComm {
* @return msg id
*/
close(
data?: any,
callbacks?: any,
metadata?: any,
data?: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string;

Expand Down Expand Up @@ -218,9 +219,9 @@ export namespace shims {
* @return msg id
*/
open(
data: any,
callbacks: any,
metadata?: any,
data: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
const future = this.jsServicesComm.open(data, metadata, buffers);
Expand All @@ -237,9 +238,9 @@ export namespace shims {
* @return message id
*/
send(
data: any,
callbacks: any,
metadata?: any,
data: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
const future = this.jsServicesComm.send(data, metadata, buffers);
Expand All @@ -255,9 +256,9 @@ export namespace shims {
* @return msg id
*/
close(
data?: any,
callbacks?: any,
metadata?: any,
data?: JSONValue,
callbacks?: ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
const future = this.jsServicesComm.close(data, metadata, buffers);
Expand Down Expand Up @@ -288,7 +289,7 @@ export namespace shims {
*/
_hookupCallbacks(
future: Kernel.IShellFuture,
callbacks: ICallbacks
callbacks?: ICallbacks
): void {
if (callbacks) {
future.onReply = function (msg): void {
Expand Down
6 changes: 3 additions & 3 deletions packages/base/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import $ from 'jquery';

import { NativeView } from './nativeview';

import { JSONObject } from '@lumino/coreutils';
import { JSONObject, JSONValue } from '@lumino/coreutils';

import { Message, MessageLoop } from '@lumino/messaging';

Expand Down Expand Up @@ -164,8 +164,8 @@ export class WidgetModel extends Backbone.Model {
* Send a custom msg over the comm.
*/
send(
content: {},
callbacks: {},
content: JSONValue,
callbacks?: ICallbacks,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): void {
if (this.comm !== undefined) {
Expand Down
17 changes: 11 additions & 6 deletions packages/controls/test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import * as widgets from '@jupyter-widgets/base';
import * as services from '@jupyterlab/services';
import { DummyManager } from './dummy-manager';

import type { JSONValue, JSONObject } from '@lumino/coreutils';

let numComms = 0;

export class MockComm implements widgets.IClassicComm {
Expand All @@ -30,8 +32,9 @@ export class MockComm implements widgets.IClassicComm {
}

open(
data?: any,
metadata?: any,
data: JSONValue,
callbacks?: widgets.ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
if (this._on_open) {
Expand All @@ -41,8 +44,9 @@ export class MockComm implements widgets.IClassicComm {
}

close(
data?: any,
metadata?: any,
data?: JSONValue,
callbacks?: widgets.ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
if (this._on_close) {
Expand All @@ -52,8 +56,9 @@ export class MockComm implements widgets.IClassicComm {
}

send(
data?: any,
metadata?: any,
data: JSONValue,
callbacks?: widgets.ICallbacks,
metadata?: JSONObject,
buffers?: ArrayBuffer[] | ArrayBufferView[]
): string {
return '';
Expand Down