Can't build/install my own extension any more (Type Uint8Array is not generic)

Hello,

a year ago, I created my own extension, which normally installed without any problems. I haven’t changed anything in this extension for months and am now getting the following error message: error TS2315: Type ‘Uint8Array’ is not generic.

Unfortunately, I am not familiar with all the dependencies and the dependencies of the dependencies. I just followed the template for the extension and added my code to it.

I hope you can help me.
Thank you very much.

error message:

#8 108.6       ➤ YN0013: │ yargs-parser@npm:20.2.9 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yjs@npm:13.6.27 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yargs-parser@npm:20.2.9 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yjs@npm:13.6.27 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0013: │ typescript@npm:5.0.4 can't be found in the cache and will be fetched from the remote registry
#8 108.6       ➤ YN0000: └ Completed in 26s 311ms
#8 108.6       ➤ YN0000: ┌ Link step
#8 108.6       ➤ YN0007: │ @fortawesome/fontawesome-free@npm:5.15.4 must be built because it never has been before or the last one failed
#8 108.6       ➤ YN0000: └ Completed in 5s 898ms
#8 108.6       ➤ YN0000: Done with warnings in 40s 296ms
#8 108.6       INFO:hatch_jupyter_builder.utils:> /tmp/pip-build-env-fh883wc2/overlay/bin/jlpm run build:prod
#8 108.6       node_modules/lib0/encoding.d.ts(6,11): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       node_modules/lib0/encoding.d.ts(13,53): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       node_modules/lib0/encoding.d.ts(146,21): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       node_modules/lib0/encoding.d.ts(172,21): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       node_modules/lib0/encoding.d.ts(208,21): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       node_modules/lib0/encoding.d.ts(231,21): error TS2315: Type 'Uint8Array' is not generic.
#8 108.6       Traceback (most recent call last):
#8 108.6         File "/opt/conda/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
#8 108.6           main()
#8 108.6         File "/opt/conda/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
#8 108.6           json_out['return_val'] = hook(**hook_input['kwargs'])
#8 108.6                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#8 108.6         File "/opt/conda/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
#8 108.6           whl_basename = backend.build_wheel(metadata_directory, config_settings)
#8 108.6                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#8 108.6         File "/tmp/pip-build-env-fh883wc2/overlay/lib/python3.11/site-packages/hatchling/build.py", line 58, in build_wheel
#8 108.6           return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard'])))
#8 108.6                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#8 108.6         File "/tmp/pip-build-env-fh883wc2/overlay/lib/python3.11/site-packages/hatchling/builders/plugin/interface.py", line 147, in build
#8 108.6           build_hook.initialize(version, build_data)
#8 108.6         File "/tmp/pip-build-env-fh883wc2/normal/lib/python3.11/site-packages/hatch_jupyter_builder/plugin.py", line 94, in initialize
#8 108.6           raise e
#8 108.6         File "/tmp/pip-build-env-fh883wc2/normal/lib/python3.11/site-packages/hatch_jupyter_builder/plugin.py", line 89, in initialize
#8 108.6           build_func(self.target_name, version, **build_kwargs)
#8 108.6         File "/tmp/pip-build-env-fh883wc2/normal/lib/python3.11/site-packages/hatch_jupyter_builder/utils.py", line 117, in npm_builder
#8 108.6           run([*npm_cmd, "run", build_cmd], cwd=str(abs_path))
#8 108.6         File "/tmp/pip-build-env-fh883wc2/normal/lib/python3.11/site-packages/hatch_jupyter_builder/utils.py", line 231, in run
#8 108.6           return subprocess.check_call(cmd, **kwargs)
#8 108.6                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#8 108.6         File "/opt/conda/lib/python3.11/subprocess.py", line 413, in check_call
#8 108.6           raise CalledProcessError(retcode, cmd)
#8 108.6       subprocess.CalledProcessError: Command '['/tmp/pip-build-env-fh883wc2/overlay/bin/jlpm', 'run', 'build:prod']' returned non-zero exit status 1.
#8 108.6       [end of output]
#8 108.6
#8 108.6   note: This error originates from a subprocess, and is likely not a problem with pip.
#8 108.6 error: metadata-generation-failed
#8 108.6
#8 108.6 × Encountered error while generating package metadata.
#8 108.6 ╰─> See above for output.

Dockerfile:

ARG BASE_IMAGE=quay.io/jupyter/minimal-notebook:hub-4.1.5
FROM ${BASE_IMAGE}

ENV PIP_NO_CACHE_DIR=false

USER root
...
COPY jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config.py
USER ${NB_UID}
RUN pip install  --no-cache-dir nbgitpuller ipympl pandas matplotlib numpy ipywidgets scipy git+(MyExtension)

# Disable nbdime, Copy Shareable Link
RUN jupyter labextension disable nbdime-jupyterlab && \
    jupyter labextension disable @jupyterlab/filebrowser-extension:share-file

RUN fix-permissions ${CONDA_DIR} && \
    fix-permissions /home/${NB_USER}

package.json

....
    "dependencies": {
        "@jupyterlab/application": "^4.0.0",
        "@jupyterlab/coreutils": "^6.0.0",
        "@jupyterlab/services": "^7.0.0",
        "@jupyterlab/settingregistry": "^4.0.0"
    },
    "devDependencies": {
        "@jupyterlab/builder": "^4.0.0",
        "@types/json-schema": "^7.0.11",
        "@types/react": "^18.0.26",
        "@types/react-addons-linked-state-mixin": "^0.14.22",
        "@typescript-eslint/eslint-plugin": "^6.1.0",
        "@typescript-eslint/parser": "^6.1.0",
        "css-loader": "^6.7.1",
        "eslint": "^8.36.0",
        "eslint-config-prettier": "^8.8.0",
        "eslint-plugin-prettier": "^5.0.0",
        "mkdirp": "^1.0.3",
        "npm-run-all": "^4.1.5",
        "prettier": "^3.0.0",
        "rimraf": "^5.0.1",
        "source-map-loader": "^1.0.2",
        "style-loader": "^3.3.1",
        "stylelint": "^15.10.1",
        "stylelint-config-recommended": "^13.0.0",
        "stylelint-config-standard": "^34.0.0",
        "stylelint-csstree-validator": "^3.0.0",
        "stylelint-prettier": "^4.0.0",
        "typescript": "~5.0.2",
        "yjs": "^13.5.0"
    },
....

I had the same problem as you, and just lost the best part of three to four hours of my life trying to fix this.

The fix[1] I finally settled on was to add skipLibCheck and set it to ‘true’ in my tsconfig.json file.

The longer story[2]…

Part of the confusion is I had another extension that installed fine (after I just re-used the ‘copier’ template and copied back in my source code) but these two others did not. The difference was that my other two extensions were written TypeScript.

Cheers

[1] jupyterlab-reveal/tsconfig.json at 4eeacedcdafbf7e9d492468968ce239a37f24bed · corememltd/jupyterlab-reveal · GitHub
[2] lib0 (dep of yjs)[1] is bust for TS <5.7 but vscode-jsonrpc (why is t… · corememltd/jupyterlab-reveal@4eeaced · GitHub

1 Like

I found another solution.
If I understood correctly, the dependency lib0 was built ~2 weeks ago with TypeScript > 5.7. That’s why I replaced ‘typescript’: ‘~5.0.2’ with “typescript”: ‘~5.7.0’ in the package.json.
This allowed me to build it without any problems.

1 Like

Thanks for the report and providing details :+1:

For what it’s worth, the recurring check on the extension-template has been failing for the past 3 weeks: CI · Workflow runs · jupyterlab/extension-template · GitHub

Which does seem to coincide with the latest release of lib0 Release v0.2.114 · dmonad/lib0 · GitHub

1 Like

Looking into Upgrade typescript dependency by brichet · Pull Request #107 · jupyterlab/extension-template · GitHub, which should hopefully help fix the issue.

1 Like

Looks like CI is now passing with Upgrade typescript dependency by brichet · Pull Request #107 · jupyterlab/extension-template · GitHub (thanks to @brichet).

Hopefully this fixes the issue you were getting, otherwise don’t hesitate to comment here, thanks!

1 Like