apache / apache/echarts

[Feature] Reference types of option properties easily

Open
#17,272 0 comments 7 reactions 0 assignees View on GitHub
en enhancement 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?

I've found that it is quite hard to use types with ECharts. For instance, I wanted to create a function that was my default tooltip formatter (to reuse the code).

The type it should have is:
```ts
formatter?: string | TooltipFormatterCallback;
```

However, these types are not exported. I tried to pick the type using typescript-->
```
ECOption["tooltip"]["formatter"]
```

But the formatter can either be an array or a single object so typescript doesn't allow me to do this.

Similar things happen with xAxis and others (all the types that are `Arrayable`). I just don't know how to get the types or infer them in some way.

Maybe I'm missing something. If I am maybe, adding a small explanation in the docs could prove helpful.

### What does the proposed API look like?

Export the typings of individual options so that they can be used easily

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.