Skip to content

Commit 3148ca3

Browse files
authored
Merge pull request #3570 from vidartf/unpack-typing
Stricter typescript + some cleanups
2 parents e2e05e2 + 6c7a74e commit 3148ca3

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

packages/base/src/services-shim.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { Kernel, KernelMessage } from '@jupyterlab/services';
1313
* Callbacks for services shim comms.
1414
*/
1515
export interface ICallbacks {
16-
shell?: { [key: string]: (msg: KernelMessage.IMessage) => void };
17-
iopub?: { [key: string]: (msg: KernelMessage.IMessage) => void };
18-
input?: (msg: KernelMessage.IMessage) => void;
16+
shell?: { [key: string]: (msg: KernelMessage.IShellMessage) => void };
17+
iopub?: { [key: string]: (msg: KernelMessage.IIOPubMessage) => void };
18+
input?: (msg: KernelMessage.IStdinMessage) => void;
1919
}
2020

2121
export interface IClassicComm {

packages/base/src/widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { KernelMessage } from '@jupyterlab/services';
3434
*/
3535
export function unpack_models(
3636
value: any | Dict<unknown> | string | (Dict<unknown> | string)[],
37-
manager: IWidgetManager
37+
manager?: IWidgetManager // actually required, but typed to be compatible with ISerializers
3838
): Promise<WidgetModel | Dict<WidgetModel> | WidgetModel[] | any> {
3939
if (Array.isArray(value)) {
4040
const unpacked: any[] = [];
@@ -50,7 +50,7 @@ export function unpack_models(
5050
return utils.resolvePromisesDict(unpacked);
5151
} else if (typeof value === 'string' && value.slice(0, 10) === 'IPY_MODEL_') {
5252
// get_model returns a promise already
53-
return manager.get_model(value.slice(10, value.length));
53+
return manager!.get_model(value.slice(10, value.length));
5454
} else {
5555
return Promise.resolve(value);
5656
}

packages/controls/src/widget_controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ export class ControllerView extends DOMWidgetView {
389389
const dummy = new Widget();
390390
this.button_box.addWidget(dummy);
391391

392-
return this.create_child_view(model)
393-
.then((view: ControllerButtonView) => {
392+
return this.create_child_view<ControllerButtonView>(model)
393+
.then((view) => {
394394
// replace the dummy widget with the new one.
395395
const i = ArrayExt.firstIndexOf(this.button_box.widgets, dummy);
396396
this.button_box.insertWidget(i, view.luminoWidget);
@@ -406,8 +406,8 @@ export class ControllerView extends DOMWidgetView {
406406
const dummy = new Widget();
407407
this.axis_box.addWidget(dummy);
408408

409-
return this.create_child_view(model)
410-
.then((view: ControllerAxisView) => {
409+
return this.create_child_view<ControllerAxisView>(model)
410+
.then((view) => {
411411
// replace the dummy widget with the new one.
412412
const i = ArrayExt.firstIndexOf(this.axis_box.widgets, dummy);
413413
this.axis_box.insertWidget(i, view.luminoWidget);

packages/controls/src/widget_selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ export class RadioButtonsView extends DescriptionView {
317317
update(options?: any): void {
318318
const items: string[] = this.model.get('_options_labels');
319319
const radios = Array.from(
320-
this.container.querySelectorAll('input[type="radio"]')
321-
).map((x: HTMLInputElement) => x.value);
320+
this.container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
321+
).map((x) => x.value);
322322
let stale = items.length !== radios.length;
323323

324324
if (!stale) {

tsconfigbase.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"strict": true,
1919
"noImplicitThis": false,
2020
"strictPropertyInitialization": false,
21-
"strictFunctionTypes": false,
2221
"target": "es2017"
2322
}
2423
}

0 commit comments

Comments
 (0)