apache / apache/echarts

Export types for formatter callback params

Open
#14,277 7 comments 41 reactions 0 assignees View on GitHub
new-feature typescript
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### What problem does this feature solve?
would allow to define callback formatter with properly typed arguments: for now I have to type ``params`` to ``any``, loosing typing within the formatter function. For instance:

tooltip.formatter = (params: any) => {
// access to whatever in params is allowed
...
return content;
};

### What does the proposed API look like?
As I get it, ``params`` is expected to be of ``FormatterParams`` type, so exporting in within echarts.d.ts would allow something along the line of :

import {FormatterParams} from "echarts";

...
tooltip.formatter = (params: FormatterParams) => {
// compilation error on access to something to defined in FormatterParams
return content;
};

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.