Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module d3 or its corresponding type declarations #2362

Closed
TobiasKrok opened this issue Aug 13, 2022 · 6 comments
Closed

Cannot find module d3 or its corresponding type declarations #2362

TobiasKrok opened this issue Aug 13, 2022 · 6 comments
Assignees

Comments

@TobiasKrok
Copy link

Describe the Bug

After updating to v10, builds fail because it fails to find d3 or d3-transitions

node_modules/react-flow-renderer/dist/esm/types/general.d.ts:2:56 - error TS2307: Cannot find module 'd3' or its corresponding type declarations.

2 import { Selection as D3Selection, ZoomBehavior } from 'd3';
                                                         ~~~~

node_modules/react-flow-renderer/dist/esm/utils/graph.d.ts:1:42 - error TS2307: Cannot find module 'd3' or its corresponding type declarations.

1 import { Selection as D3Selection } from 'd3';
                                           ~~~~

node_modules/react-flow-renderer/dist/esm/utils/graph.d.ts:15:128 - error TS7016: Could not find a declaration file for module 'd3-transition'. 'C:/monolith/packages/hub/node_modules/d3-transition/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/d3-transition` if it exists or add a new declaration (.d.ts) file containing `declare module 'd3-transition';`

15 export declare const getD3Transition: (selection: D3Selection<Element, unknown, null, undefined>, duration?: number) => import("d3-transition").Transition<Element, unknown, null, undefined>;     
                                                                                                                                  ~~~~~~~~~~~~~~~

I'm using Vite v2.6.4 to build the package.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Install react-flow-renderer
  2. run tsc && vite build
  3. Build fails

Expected behavior

Build with no errors

Screenshots or Videos

No response

Platform

react-flow-renderer: v10.3.14
vite: 2.6.3
react: 18.2.0

Additional context

No response

@moklick
Copy link
Member

moklick commented Aug 15, 2022

I can't reproduce this. My steps:

  1. create new project with npm create vite@latest
  2. npm install --save react-flow-renderer
  3. add basic example
  4. run tsc && vite build - there are no issues

@types/d3 is part of the devDependecies.

@moklick moklick self-assigned this Aug 15, 2022
@sushantdhiman
Copy link

+1

@moklick You need to set skipLibCheck: false in project's tsconfig.json, so that type check can be performed on node_modules. As error is with distributed production types, @types/d3 needs to be a production dependency for react-flow-renderer,

@moklick
Copy link
Member

moklick commented Aug 16, 2022

added @types to dependencies in v10.3.15

@barneaoren
Copy link

@moklick - Seems that while adding the @types in V10.3.15 you forced everyone to install @types/react and @types/react-dom v18 which is not compatible with React v16.
As this is a breaking change, this should be either reverted back to the previous state (devDependency) or the entire change should be part of a major version bump.

For now I am going to freeze my application on the previous version to mitigate the problem I'm seeing

@sushantdhiman
Copy link

Hi @moklick , It is not necessary to include the react and react-dom types because they are peer dependencies that should be installed by consuming projects.

@moklick
Copy link
Member

moklick commented Aug 17, 2022

@barneaoren @sushantdhiman Thanks! This is fixed in v10.3.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants