Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript: "react" has no exported member named 'ForwardedRef' #870

Closed
ferreiratiago opened this issue Nov 16, 2021 · 4 comments · Fixed by #987
Closed

Typescript: "react" has no exported member named 'ForwardedRef' #870

ferreiratiago opened this issue Nov 16, 2021 · 4 comments · Fixed by #987
Assignees
Labels

Comments

@ferreiratiago
Copy link

Problem

Currently there's a problem with the exported function ForwardedRef on file scr/types.ts.

This problem was introduced on #782 (https://github.com/reactchartjs/react-chartjs-2/pull/782/files#diff-c54113cf61ec99691748a3890bfbeb00e10efb3f0a76f03a0fd9ec49072e410aR3).

This causes the Typescript compiler to fail with the following problems:

> tsc

node_modules/react-chartjs-2/dist/chart.d.ts:4:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

4     ref?: React.ForwardedRef<import("./types").ChartJSOrUndefined<TType, TData, TLabel>> | undefined;
                  ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:4:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

4     ref?: React.ForwardedRef<ChartJSOrUndefined<"line", TData, TLabel>> | undefined;
                  ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:7:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

7     ref?: React.ForwardedRef<ChartJSOrUndefined<"bar", TData, TLabel>> | undefined;
                  ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:10:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

10     ref?: React.ForwardedRef<ChartJSOrUndefined<"radar", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:13:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

13     ref?: React.ForwardedRef<ChartJSOrUndefined<"doughnut", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:16:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

16     ref?: React.ForwardedRef<ChartJSOrUndefined<"polarArea", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:19:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

19     ref?: React.ForwardedRef<ChartJSOrUndefined<"bubble", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:22:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

22     ref?: React.ForwardedRef<ChartJSOrUndefined<"pie", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/typedCharts.d.ts:25:17 - error TS2724: 'React' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

25     ref?: React.ForwardedRef<ChartJSOrUndefined<"scatter", TData, TLabel>> | undefined;
                   ~~~~~~~~~~~~

node_modules/react-chartjs-2/dist/types.d.ts:1:37 - error TS2724: '"react"' has no exported member named 'ForwardedRef'. Did you mean 'forwardRef'?

1 import type { CanvasHTMLAttributes, ForwardedRef, ReactNode, MouseEvent } from 'react';
                                      ~~~~~~~~~~~~

  node_modules/@types/react/index.d.ts:801:14
    801     function forwardRef<T, P = {}>(render: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
                     ~~~~~~~~~~
    'forwardRef' is declared here.


Found 10 errors.
@dangreen
Copy link
Collaborator

@ferreiratiago Hi.

  1. What version of @types/react are you using?
  2. Would you please fork this sandbox and reproduce the problem?

@dangreen
Copy link
Collaborator

dangreen commented Dec 3, 2021

@ferreiratiago Is this issue still relevant for you?

@sergiu-paraschiv
Copy link

I was able to reproduce this using @types/react and @types/react-dom ^16.14.0. Switching to ^17.0.0 fixes this, though might not be a good idea if you are not using react 17.

I was not able to reproduce this in codesandbox, it does not seem to use tsc so it does not check types of node_modules dependencies probably.

@dangreen dangreen self-assigned this Dec 6, 2021
@dangreen dangreen added the bug label Dec 6, 2021
@AwesomeZaidi
Copy link

I'm experiencing this issue as well. Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants