Skip to content

Widget Typescript errors #12

@cw00dw0rd

Description

@cw00dw0rd

Description

When attempting to build the project, I am receiving Typescript errors.
I was following along with the tutorial, and the first time a Widget was introduced, it reported errors.
I decided to try and copy the final version from the repo and received the same error about the updated APODWidget

I pasted my error output in the CLI output below

Reproduce

  1. Follow the steps from here: https://jupyterlab.readthedocs.io/en/stable/extension/extension_tutorial.html#extension-tutorial
  2. Add the widget code to the activate section

Expected behavior

Context

  • Operating System and version: Ubunut 20.04 (wsl2)
  • Browser and version: Chrome
  • JupyterLab version: 3.61
Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
jlpm run build
yarn run v1.21.1
$ jlpm build:lib && jlpm build:labextension:dev
$ tsc --sourceMap
src/index.ts:111:30 - error TS2344: Type 'APODWidget' does not satisfy the constraint 'Widget'.
  Types of property 'title' are incompatible.
    Property 'iconRenderer' is missing in type 'import("/home/cw00dw0rd/development/jupyter-tutorial/jupyterlab_apod/node_modules/@lumino/widgets/types/title").Title' but required in type 'import("/home/cw00dw0rd/development/jupyter-tutorial/jupyterlab_apod/node_modules/@jupyterlab/apputils/node_modules/@lumino/widgets/types/title").Title'.

111 let widget: MainAreaWidget;
~~~~~~~~~~

node_modules/@jupyterlab/apputils/node_modules/@lumino/widgets/types/title.d.ts:100:5
100 iconRenderer: VirtualElement.IRenderer | undefined;
~~~~~~~~~~~~
'iconRenderer' is declared here.

src/index.ts:122:9 - error TS2322: Type 'MainAreaWidget' is not assignable to type 'MainAreaWidget'.
Type 'Widget' is missing the following properties from type 'APODWidget': img, summary, randomDate

122 widget = new MainAreaWidget({ content });
~~~~~~

src/index.ts:122:39 - error TS2322: Type 'APODWidget' is not assignable to type 'Widget'.

122 widget = new MainAreaWidget({ content });
~~~~~~~

node_modules/@jupyterlab/apputils/lib/mainareawidget.d.ts:100:9
100 content: T;
~~~~~~~
The expected type comes from property 'content' which is declared here on type 'IOptions'

src/index.ts:146:50 - error TS2344: Type 'APODWidget' does not satisfy the constraint 'Widget'.

146 let tracker = new WidgetTracker<MainAreaWidget>({
~~~~~~~~~~

Found 4 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Browser Output
Paste the output from your browser Javascript console here, if applicable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions