apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.17k stars 19.6k forks source link

Type for datazoom event #19571

Open akopanskiy opened 7 months ago

akopanskiy commented 7 months ago

Version

5.4.3

Link to Minimal Reproduction

No response

Steps to Reproduce

Create datazoom event Try to type

Current Behavior

For example, we have the following code: `myChart.on("dataZoom", event => { if (event.batch) { return dataZoom.value = { start: event.batch[0].start, end: event.batch[0].end }; }

            dataZoom.value = { start: event.start, end: event.end };
        });`

For the event TypeScript gives an error: Argument of type (this: EChartsType, e: unknown) => { start: any; end: any; } | undefined is not assignable to parameter of type WithThisType<(...args: unknown[]) => boolean | void, EChartsType> How to type an event?

Expected Behavior

-

Environment

- OS: macOS Sonoma
- Browser: Chrome 120.0.6099.129 
- Framework: Vue@3

Any additional comments?

No response

helgasoft commented 7 months ago

this code has no errors:

myChart.on('dataZoom', (event: any) => {
  var dz = { start: event.start, end: event.end };
  if (event.batch)
    dz = { start: event.batch[0].start, end: event.batch[0].end };
  console.log(dz);
});

📌 please close issue if problem solved.

ievgennaida commented 1 month ago

Same problem, event has no type defined.