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

**URL:** <https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497>\
**Category:** ROOT\
**Tags:** jsroot\
**Created:** [May 28, 2024, 7:53pm UTC](https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497 "2024-05-28T19:53:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 28, 2024, 7:53pm UTC](https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497/1 "2024-05-28T19:53:00Z")

</div>

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

```auto
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:

```auto
14c14,18
< ".": "./modules/main.mjs",
---
> ".": {
> "import": "./modules/main.mjs",
> "require": "./build/jsroot.js",
> "types": "./types.d.ts"
> },
134a139
> 

```

@linev

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [May 29, 2024, 6:28am UTC](https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497/2 "2024-05-29T06:28:41Z")

</div>

Can you create PR for the repository?

---

<div class="post-metadata">

**Author:** ![wiso](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wiso/32/11120_2.png) [@wiso](https://root-forum.cern.ch/u/wiso)\
**Post date:** [May 29, 2024, 8:28am UTC](https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497/3 "2024-05-29T08:28:03Z")

</div>

Sure, [export types.d.ts by wiso · Pull Request #310 · root-project/jsroot · GitHub](https://github.com/root-project/jsroot/pull/310)  
Take into account I am no expert of javascript or node.js

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 12, 2024, 8:28am UTC](https://root-forum.cern.ch/t/typescript-problem-with-jsroot-could-not-find-a-declaration-file-for-module-jsroot/59497/4 "2024-06-12T08:28:37Z")

</div>

Closed on June 12, 2024, 8:28am UTC

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