ScalablyTyped/Converter

Invalid imports when types are exported from a different location than the js

steinybot opened this issue · 0 comments

There is at least one problem when ST converts something like https://www.npmjs.com/package/react-error-boundary.

It has the following layout:
Screenshot 2024-03-04 at 2 43 14 PM

ST ends up generating this:

    @JSImport("react-error-boundary/dist/declarations/src/ErrorBoundary", "ErrorBoundary")
    @js.native
    val component: js.Object = js.native

This will fail as there is no module at react-error-boundary/dist/declarations/src/ErrorBoundary.

Trying to workaround it using alias from webpack is problematic too since there is no way to convert everything under react-error-boundary/dist/declarations/src to a single module react-error-boundary. I'm pretty sure I have to list every file one by one.

I'm not entirely sure how this should be reconciled but it needs to do something different.

dist/react-error-boundary.cjs.d.ts has:

export * from "./declarations/src/index";
//# sourceMappingURL=react-error-boundary.cjs.d.ts.map

So any imports cannot use ./declarations/src/index that's for sure.

So should everything be rebased onto the main entry point?

They also need to match the exports although perhaps that will be right if we get the first part right.