echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] getOption() 返回的类型不匹配

Open zhl1232 opened this issue 2 years ago • 1 comments

Version

e.g.5.3.2

Link to Minimal Reproduction

No response

Steps to Reproduce

  1. 使用 TypeScript
  2. 调用 instance.getOption() 返回类型提示是 ECBasicOption,但实际返回类似于 { title: [{...}], legend: [{...}], grid: [{...}] }
  3. 所以使用 instance.getOption().legend[0] 会提示类型错误 元素隐式具有 "any" 类型,因为类型为 "0" 的表达式不能用于索引类型 "{}"。 类型“{}”上不存在属性“0”。

Current Behavior

instance.getOption() 返回类型错误

Expected Behavior

instance.getOption() 返回类型和实际一至

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

zhl1232 avatar Sep 08 '22 03:09 zhl1232

@zhl1232 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Bug] getOption() returns a type mismatch

BODY

Version

e.g.5.3.2

Link to Minimal Reproduction

No response

Steps to Reproduce

  1. Using TypeScript
  2. Calling instance.getOption() returns the type hint is ECBasicOption, but the actual return is something like { title: [{...}], legend: [{...}], grid: [{...}] }
  3. So using instance.getOption().legend[0] will prompt a type error Element implicitly has type 'any' because expressions of type '0' cannot be used for index type '{}'. Property '0' does not exist on type '{}'.

Current Behavior

instance.getOption() returns the wrong type

Expected Behavior

instance.getOption() return type and actual one to

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

echarts-bot[bot] avatar Sep 08 '22 03:09 echarts-bot[bot]