mobxjs / mobx-react-lite

Lightweight React bindings for MobX based on React 16.8 and Hooks
https://mobx.js.org/react-integration.html
MIT License
2.13k stars 90 forks source link

Namespace 'React' has no exported member 'RefForwardingComponent'. #263

Closed rschristian closed 3 years ago

rschristian commented 4 years ago

Intended outcome

I'm building an application, and after doing some work with MobX, I ran a production build to ensure everything was working as expected, but it errored out. Development build does work exactly as intended, however.

Actual outcome

I get the following error:

✖ ERROR ./node_modules/mobx-react-lite/dist/observer.d.ts
ERROR in ./node_modules/mobx-react-lite/dist/observer.d.ts(5,84):
TS2694: Namespace 'React' has no exported member 'RefForwardingComponent'.

How to reproduce the issue

Creating a simple component will trigger the issue:

export const Example: FunctionalComponent<Issue> = observer((props: Issue) => {
    ...
});

Nothing more advanced than this needed.

Versions

"mobx": "^5.15.4",
"mobx-react-lite": "^1.5.2",
"@types/react": "16.9.19",

Browsing through @types/react, I did notice they deprecated RefForwardingComponent, but even going to an older version (16.9.19) didn't fix this problem. Strangely, if I edit observer.d.ts in node_modules, and import React there (import React from 'react';), the production build works just fine. Just something I noticed.

danielkcz commented 4 years ago

That looks like some issue on your side given that interface is still exported in the latest version.

PR is welcome nonetheless to fix deprecation.

rschristian commented 4 years ago

You're right, it was something in my configuration. Sorry.

danielkcz commented 3 years ago

Closing for now as it doesn't really bother anyone. PR is there, it might need some updating, but not worth the trouble for now.