re-rxjs / react-rxjs

React bindings for RxJS
https://react-rxjs.org
MIT License
542 stars 17 forks source link

TypeScript moduleResolution: NodeNext expects core.es2017.d.ts types file #298

Closed bmcbarron closed 1 year ago

bmcbarron commented 1 year ago

NodeNext module resolution strictly obeys exports, so for any exported file xxx.js, it looks for types in xxx.d.ts. I'm importing @react-rxjs/core in a web context, which maps to ./dist/core.es2017.js. Therefore, TypeScript expects the types to be found in ./dist/core.es2017.d.ts.

According to https://github.com/microsoft/TypeScript/issues/52363, this behavior is by design, and the recommended course of action is to update the types files in the imported package. It seems unfortunate that multiple copies of the types file are needed, but I suppose each export version might actually have different types, which is why this would be needed.

Update: @rx-state/core is a type dependency of @react-rxjs/core. Fixing both is required for clean compilation. I suspect multiple other sibling libraries share the same issue.