Open NickeyLin opened 5 years ago
Hi, @NickeyLin First of all thank you for the issue.
The problem is known and it is related with inconsistent documentation in documentation at the moment of typings generation.
This tool is trying to retrieve types from the content of fields as they are more verbose and correct. For example if fontWeight
can contain only values 'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 | 300 | 400
so this type will be more correct than just 'string'.
However because of fields' content descriptions are different between series
so it is very hard to parse all cases. If the tool cannot correctly parse content of some field than it will use the type placed beside the rule name.
Actually this tool works tricky way trying to parse data not from the source. Maybe the source of the docs is more consistent and generated result will be much better. I'll write here details on finish the investigation.
Issue Details
TypeScript 声明文件 SeriesBar.markPoint.data 类型声明有误。而且感觉整个声明文件很乱,有些应该相同的类型,因为在不同的series中,类型却不一样,比如
fontWeight
,有些地方声明为:'normal' | 'bold' | 'bolder' | 'lighter' | 100 | 200 | 300 | 400
,有些地方却只是简单的string
。Expected Behavior
在TypeScript中能正确使用柱形图的markPoint,并且希望TypeScript声明更加规范一点。
Current Behavior
下面语句会报错
错误信息
markPoint.data 应该是数组类型,但是声明文件里面却是object。
Online Example
Topics
Anything Else We Need to Know
Environment
ECharts version;ECharts 版本: {@4.2.0-rc.2} @types/echarts 版本:{4.1.3}
[ ] It happens only on certain browsers or operating systems. 对于特定浏览器或操作系统才会出现的问题,请提供相应环境信息:{BROWSER_VERSION_OR_OS_INFORMATION_HERE}