chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
606 stars 328 forks source link

TypeScript: `xMin`, `xMax`, `yMin`, `yMax` should accept undefined value as Scriptable options return value #921

Open tlserver opened 10 months ago

tlserver commented 10 months ago

The four options xMin, xMax, yMin, and yMax can accept an undefined value to indicate "growth to the chart boundary." Scriptable options for these four options also support an undefined value. However, TypeScript has incorrectly defined the types for these four options:

  xMax?: Scriptable<ScaleValue, PartialEventContext>,
  xMin?: Scriptable<ScaleValue, PartialEventContext>,
  yMax?: Scriptable<ScaleValue, PartialEventContext>,
  yMin?: Scriptable<ScaleValue, PartialEventContext>,

Using (_, __) => undefined should be a valid assignment, but currently, TypeScript raises a type error.