bkrem/react-d3-tree

Cannot find a declaration file for module

keduong33 opened this issue · 3 comments

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

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';

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

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

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