react-component / virtual-list

🧾 React Virtual List Component which worked with animation
https://rc-virtual-list.react-component.now.sh
MIT License
730 stars 155 forks source link

Namespace 'React' has no exported member 'JSX' #203

Open kaiyoma opened 1 year ago

kaiyoma commented 1 year ago

Version 3.5.1 is throwing a type error from inside node_modules:

../../common/temp/node_modules/.pnpm/rc-virtual-list@3.5.1_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/rc-virtual-list@3.5.1_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/rc-virtual-list@3.5.1_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/List.d.ts:38
     1  ../../common/temp/node_modules/.pnpm/rc-virtual-list@3.5.1_sfoxds7t5ydpegc3knd667wn6m/node_modules/rc-virtual-list/lib/ScrollBar.d.ts:42
kaiyoma commented 1 year ago

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 commented 1 year ago

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

ethaizone commented 1 year ago

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"
  }