Typescript problem with jsroot: Could not find a declaration file for module 'jsroot'

when compiling a web application in typescript using jsroot I get the following error:

Type error: Could not find a declaration file for module 'jsroot'. '/home/turra/physval-web/node_modules/jsroot/modules/main.mjs' implicitly has an 'any' type.
  There are types at '/home/turra/physval-web/node_modules/jsroot/types.d.ts', but this result could not be resolved when respecting package.json "exports". The 'jsroot' library may need to update its package.json or typings.

  1 | 'use client'
  2 |
> 3 | import { openFile, isNodeJs, HierarchyPainter, draw } from 'jsroot';
    |                                                            ^

So it seems that package.json has to be updated. I am not expert, but this change solve the issue:

<     ".": "./modules/main.mjs",
>     ".": {
>       "import": "./modules/main.mjs",
>       "require": "./build/jsroot.js",
>       "types": "./types.d.ts"
>     },


Can you create PR for the repository?

Sure, export types.d.ts by wiso · Pull Request #310 · root-project/jsroot · GitHub
Take into account I am no expert of javascript or node.js

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.