bkrem / react-d3-tree

:deciduous_tree: React component to create interactive D3 tree graphs
https://bkrem.github.io/react-d3-tree
MIT License
1.06k stars 268 forks source link

Cannot find a declaration file for module #481

Closed keduong33 closed 7 months ago

keduong33 commented 9 months ago

Hi, I am using react-d3-tree for my React + TS project. I tried to import the library but it has some weird error and I am not sure if anyone encountered it before.

Are you reporting a bug, or opening a feature request?

A potential bug

What is the actual behavior/output?

The error on import Could not find a declaration file for module 'react-d3-tree'. '___/node_modules/react-d3-tree/lib/esm/index.js' implicitly has an 'any' type. There are types at ___/node_modules/react-d3-tree/lib/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'react-d3-tree' library may need to update its package.json or typings.ts(7016)

But I can still use the library fine but all the typing is gone

What is the behavior/output you expect?

Should be able to import just fine

What version of react-d3-tree are you using?

3.6.1

letelete commented 9 months ago

Same issue here. For a quick fix, create a declaration file, e.g. react-d3-tree.d.ts, and paste the following:

declare module 'react-d3-tree' {
  export * from 'node_modules/react-d3-tree/lib/types';
}

Then, you should be able to use types normally:

import { type RawNodeDatum, Tree } from 'react-d3-tree';
hyper-dot commented 7 months ago

It's still not solved. I am getting same error.

bkrem commented 7 months ago

Fixed via https://github.com/bkrem/react-d3-tree/releases/tag/v3.6.2

Thanks for sharing the workaround here in the meantime @letelete 🙏