reaviz / reaflow

🎯 React library for building workflow editors, flow charts and diagrams. Maintained by @goodcodeus.
https://reaflow.dev
Apache License 2.0
2.11k stars 122 forks source link

Could not find a declaration file for module 'reaflow', when using typescript v5, with moduleResolution set to "bundler" #221

Closed james-nair closed 1 year ago

james-nair commented 1 year ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report - I have check opening issues, and could not find related issue on this matter
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior

Importing components from "reaflow" in react project, with typescript 5.1.3 in vscode workspace, and "moduleResolution" set to "bundler" in tsconfig.json, vscode would throw a Could not find a declaration file for module 'reaflow'.

Inspecting the package.json of "reaflow" in the node_modules, in fact missing the "types" field under "export". See below: image

Expected behavior

Importing components from "reaflow" should not throw any errors in vscode.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

This bug prevent the project being able to build (at least without "noImplicitAny"; false in tsconfig.json)

Environment


Libs:
- react version: 18.2.0
- reaflow version: 5.2.0

For Tooling issues:
- Node version: v18.15.0

Others:
Vscode version: 1.80.0
Workspace typescript version: 5.1.3
james-nair commented 1 year ago

Apparently this can't be fixed with patch-package too as it doesn't comparing package.json. Anyone has any work-around? (Also thank you @amcdnl for looking into this)

amcdnl commented 1 year ago

@JimmyNair - The types export is there - https://github.com/reaviz/reaflow/blob/master/package.json#L27

james-nair commented 1 year ago

@JimmyNair - The types export is there - https://github.com/reaviz/reaflow/blob/master/package.json#L27

Hi @amcdnl , I did see the 'types' exports in the source code. However it is not reflected in the output package.json, which is being downloaded. Please see attached screenshot from npm. As you can see it's not part of the exports. image

amcdnl commented 1 year ago

Interesting - OK let me investigate

james-nair commented 1 year ago

This has resolved in version 5.2.2. Thanks @amcdnl