Skip to content

[Bug] Missing 'all or inverse' type for SelectorType #18636

@fes0j

Description

@fes0j

Version

5.4.2

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=line-stack&lang=ts

Steps to Reproduce

  1. Go to line-stack example and ensure TS is enabled
  2. Replace the legend option with
    legend: {
     data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'],
     selector: [{type: 'all or inverse'}]
    }
    
  3. 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 :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docDocument or Website related issues.enThis issue is in Englishresolved

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions