I am following the JupyterLab Extension Tutorial and came across the following error when trying to create new widgets. The related codes:
import { ICommandPalette, MainAreaWidget } from '@jupyterlab/apputils';
import { Widget } from '@lumino/widgets';
and
const newWidget = () => {
// Create a blank content widget inside of a MainAreaWidget
const content = new Widget();
const widget = new MainAreaWidget({ content });
widget.id = 'apod-jupyterlab';
widget.title.label = 'Astronomy Picture';
widget.title.closable = true;
return widget;
}
let widget = newWidget();
and the error:
(property) MainAreaWidget<T extends Widget = Widget>.IOptions<Widget>.content: Widget
The child widget to wrap.
Type 'import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@lumino/widgets/types/widget").Widget' is not assignable to type 'import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@jupyterlab/apputils/node_modules/@lumino/widgets/types/widget").Widget'.
Types of property 'title' are incompatible.
Property 'iconRenderer' is missing in type 'import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@lumino/widgets/types/title").Title<import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@lumino/widgets/types/widget").Widget>' but required in type 'import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@jupyterlab/apputils/node_modules/@lumino/widgets/types/title").Title<import("/Users/my_name/Desktop/Research/JupyterLab/jupyterlab_apod/node_modules/@jupyterlab/apputils/node_modules/@lumino/widgets/types/widget").Widget>'.ts(2322)
title.d.ts(100, 5): 'iconRenderer' is declared here.
mainareawidget.d.ts(100, 9): The expected type comes from property 'content' which is declared here on type 'IOptions<Widget>'
No quick fixes available
Dependencies:
"dependencies": {
"@jupyterlab/application": "^3.6.3",
"@jupyterlab/apputils": "^3.6.3",
"@lumino/widgets": "^2.1.0"
},
I am just closely following the tutorial and the code are copy and pasted. I am able to see the right console log in the previous step so I think I have generally got the right environments and installed the packages. I wonder why this error happens and how I can solve them. Thank you so much for any suggestions.