Version
5.4.2
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?c=line-stack&lang=ts
Steps to Reproduce
- Go to line-stack example and ensure TS is enabled
- Replace the legend option with
legend: {
data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'],
selector: [{type: 'all or inverse'}]
}
- See the error message "Type '"all or inverse"' is not assignable to type 'SelectorType'.(2322)"
Current Behavior
When using 'all or inverse' as a SelectorType in the legend options, a type error in typescript will occur.
https://echarts.apache.org/en/option.html#legend.selector shows the three types available. But only 2 will have the correct type.
Expected Behavior
The documented type should be available and not produce a type error.
Environment
- OS: Linux
- Browser: -
- Framework: Vue3
Any additional comments?
|
type SelectorType = 'all' | 'inverse'; |
seems to be the culprit in the sources.
When using as a package, this diff solved the problem:
Index: node_modules/echarts/types/dist/echarts.d.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/node_modules/echarts/types/dist/echarts.d.ts b/node_modules/echarts/types/dist/echarts.d.ts
--- a/node_modules/echarts/types/dist/echarts.d.ts
+++ b/node_modules/echarts/types/dist/echarts.d.ts (date 1684230367392)
@@ -3259,7 +3259,7 @@
getLineStyle(this: Model, excludes?: readonly (keyof LineStyleOption)[]): LineStyleProps;
}
-declare type SelectorType = 'all' | 'inverse';
+declare type SelectorType = 'all' | 'inverse' | 'all or inverse';
interface LegendSelectorButtonOption {
type?: SelectorType;
title?: string;
@@ -10916,4 +10916,4 @@
baseOption?: EChartsOption;
}
Adding the third option to the type solves the problem :-)
Version
5.4.2
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?c=line-stack&lang=ts
Steps to Reproduce
Current Behavior
When using 'all or inverse' as a SelectorType in the legend options, a type error in typescript will occur.
https://echarts.apache.org/en/option.html#legend.selector shows the three types available. But only 2 will have the correct type.
Expected Behavior
The documented type should be available and not produce a type error.
Environment
Any additional comments?
echarts/src/component/legend/LegendModel.ts
Line 60 in 38d0265
When using as a package, this diff solved the problem:
Adding the third option to the type solves the problem :-)