ChepteaCatalin commented on issue #19064:
URL: https://github.com/apache/echarts/issues/19064#issuecomment-1718004681

   @yay I suggest you use the following workaround, which appears less awkward:
   
   ```typescript
           tooltip: {
               formatter: (params: echarts.DefaultLabelFormatterCallbackParams) 
=> {
                   return `${params.name}, ${params.seriesName}`;
               }
           } as echarts.TooltipComponentOption
   ```
   
   `params` is expected to be of type `TooltipComponentFormatterCallbackParams` 
which is an alias for 
   
   ```typescript
   type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[];
   ```
   
   TypeScript will try to infer the most general type from the union that 
encompasses both possibilities even if you want to infer only 
`CallbackDataParams` type. In your case, `CallbackDataParams[]` is inferred 
because it's more general than just `CallbackDataParams`. So, you have to set 
explicitly that you want `CallbackDataParams`, which is exported as 
`DefaultLabelFormatterCallbackParams`.
   
   As mentioned in the 
[documentation](https://echarts.apache.org/en/option.html#tooltip.formatter), 
`params` can take the form of either an object or an array so I don't think 
that we should change anything in the library. @plainheart, what are your 
thoughts on this?
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to