Skip to content

Export props interfaces/types for Legend and Line #2899

Description

@siddharthp-ironfort

I am trying to export LegendProps and LineProps from recharts but while using <Legend {..props}/> and <Line {..props} />. I am getting following error.

No overload matches this call.
  Overload 1 of 2, '(props: Props | Readonly<Props>): Legend', gave the following error.
    Type '{ content?: ContentType | undefined; iconSize?: number | undefined; iconType?: IconType | undefined; layout?: LayoutType | undefined; align?: HorizontalAlignmentType | undefined; ... 480 more ...; onBBoxUpdate?: ((box: DOMRect | null) => void) | undefined; }' is not assignable to type 'IntrinsicClassAttributes<Legend>'.
      Types of property 'ref' are incompatible.
        Type 'LegacyRef<ReactElement<any, string | JSXElementConstructor<any>>> | undefined' is not assignable to type 'LegacyRef<Legend> | undefined'.
          Type '(instance: ReactElement<any, string | JSXElementConstructor<any>> | null) => void' is not assignable to type 'LegacyRef<Legend> | undefined'.
            Type '(instance: ReactElement<any, string | JSXElementConstructor<any>> | null) => void' is not assignable to type '(instance: Legend | null) => void'.
              Types of parameters 'instance' and 'instance' are incompatible.
                Type 'Legend | null' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>> | null'.
                  Type 'Legend' is missing the following properties from type 'ReactElement<any, string | JSXElementConstructor<any>>': type, key
  Overload 2 of 2, '(props: Props, context: any): Legend', gave the following error.
    Type '{ content?: ContentType | undefined; iconSize?: number | undefined; iconType?: IconType | undefined; layout?: LayoutType | undefined; align?: HorizontalAlignmentType | undefined; ... 480 more ...; onBBoxUpdate?: ((box: DOMRect | null) => void) | undefined; }' is not assignable to type 'IntrinsicClassAttributes<Legend>'.
      Types of property 'ref' are incompatible.
        Type 'LegacyRef<ReactElement<any, string | JSXElementConstructor<any>>> | undefined' is not assignable to type 'LegacyRef<Legend> | undefined'.ts(2769)
No quick fixes avail

Also, I see that the same issue was fixed for Area. Hoping to get it fixed for Legend and Line.
Here is the link of that fixe issue 2156

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priority issuesbugGeneral bug labeltypescriptPRs or Issues surrounding Types or TS refactoring

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions