Skip to content

XAxisProps.plotLines and YAxisProps.plotLines incorrectly typed as single object instead of array #559

@oisincoveney

Description

@oisincoveney

The plotLines property on XAxisProps and YAxisProps is typed as a single object, but Highcharts expects an array.

Current type in @highcharts/react:

// node_modules/@highcharts/react/options/XAxis.d.ts
plotLines?: {
    acrossPanes?: boolean;
    className?: string;
    color?: Highcharts.ColorString;
    dashStyle?: Highcharts.DashStyleValue;
    // ...
};

Correct type from highcharts:

// node_modules/highcharts/highcharts.d.ts
plotLines?: Array<XAxisPlotLinesOptions>;

The Highcharts API documentation confirms plotLines is an array.

Runtime error:

When following the incorrect types and passing a single object, Highcharts throws:

(options.plotLines || []).concat is not a function

Highcharts internally expects an array and calls .concat() on it. A single object is truthy, so the || [] fallback doesn't apply, and .concat() fails.

Expected type:

plotLines?: Array<{
    acrossPanes?: boolean;
    className?: string;
    color?: Highcharts.ColorString;
    dashStyle?: Highcharts.DashStyleValue;
    // ...
}>;

Versions:

  • @highcharts/react: 4.1.0
  • highcharts: 12.5.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions