virtual-list icon indicating copy to clipboard operation
virtual-list copied to clipboard

Namespace 'React' has no exported member 'JSX'

Open kaiyoma opened this issue 2 years ago • 3 comments

Version 3.5.1 is throwing a type error from inside node_modules:

../../common/temp/node_modules/.pnpm/[email protected]_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/List.d.ts:38:89 - error TS2694: Namespace 'React' has no exported member 'JSX'.

38 export declare function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>): React.JSX.Element;
                                                                                           ~~~

../../common/temp/node_modules/.pnpm/[email protected]_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/ScrollBar.d.ts:42:21 - error TS2694: Namespace 'React' has no exported member 'JSX'.

42     render(): React.JSX.Element;
                       ~~~


Found 2 errors in 2 files.

Errors  Files
     1  ../../common/temp/node_modules/.pnpm/[email protected]_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/List.d.ts:38
     1  ../../common/temp/node_modules/.pnpm/[email protected]_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/ScrollBar.d.ts:42

kaiyoma avatar May 16 '23 14:05 kaiyoma

I believe this problem was introduced in 3.5.0 in this commit: https://github.com/react-component/virtual-list/commit/1ff9e16db54e2bdc03669c7cd330b8ed8bc60ee5

If I forcibly downgrade to version 3.4.13, the type error goes away.

Even though this package claims that it supports any React version in its peer dependencies, it's using a very new version of @types/react, which works only with React 18. We're using React 17 in our project, so that's why we're seeing this error. Seems like either the version of @types/react should be downgraded/reverted, or the peer dependencies should be updated to reflect reality.

kaiyoma avatar May 16 '23 16:05 kaiyoma

Also see https://github.com/react-component/tree/issues/746.

kaiyoma avatar May 29 '23 07:05 kaiyoma

It happen because this changed. https://github.com/DefinitelyTyped/DefinitelyTyped/commit/f1b25591890978a92c610ce575ea2ba2bbde6a89

I'm not sure if this can help but you might try to add this in your package.json.

  "resolutions": {
    "@types/react": "^18.2.12"
  }

ethaizone avatar Jun 15 '23 02:06 ethaizone