antvis/G6

Vite+React compiles G6 dependencies with an error #6414

lvyahui8 posted onGitHub

Describe the bug / 问题描述

npm run dev 可以正常运行。但在npm run build 报错,且仅有G6的包报错。尝试过调整各种compilerOptions依然无法编译通过。在当前项目Issues和网上未找到类似问题

https://github.com/lvyahui8/ellyn/tree/main/viewer

Steps to Reproduce the Bug or Issue / 重现步骤

git clone https://github.com/lvyahui8/ellyn.git
cd ellyn/viewer
npm run build

版本信息

  • "vite": "^5.4.1"
  • "react": "^18.3.1",
  • "@antv/g6": "^5.0.25",

操作系统:windows 10 64位 处理器:AMD Ryzen 7 4800U

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

Windows

Browser / 浏览器

Chrome

Additional context / 补充说明

报错内容如下:

"C:\Program Files\nodejs\npm.cmd" run build

> viewer@0.0.0 build  
> tsc -b && vite build

node_modules/@antv/g6/src/elements/nodes/html.ts:111:7 - error TS2578: Unused '@ts-expect-error' directive.

111       // @ts-expect-error assert event is PointerEvent                                                 
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                 

node_modules/@antv/g6/src/elements/nodes/html.ts:125:7 - error TS2578: Unused '@ts-expect-error' directive.

125       // @ts-expect-error assert event is PointerEvent                                                 
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                 

node_modules/@antv/g6/src/plugins/bubble-sets.ts:102:11 - error TS2322: Type 'any' is not assignable to type 'never'.

102           acc.bubbleSetOptions[key as keyof IBubbleSetOptions] = rest[key];
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6/src/plugins/bubble-sets.ts:104:11 - error TS2322: Type 'any' is not assignable to type 'never'.

104           acc.style[key as keyof ContourStyleProps] = rest[key];
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6/src/plugins/legend.ts:2:36 - error TS2307: Cannot find module '@antv/component/lib/ui/legend/types' or its corresponding type declarations.

2 import { CategoryStyleProps } from '@antv/component/lib/ui/legend/types';
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6/src/plugins/watermark/index.ts:217:9 - error TS2578: Unused '@ts-expect-error' directive.

217         // @ts-expect-error ignore
            ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6/src/runtime/data.ts:305:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'NodeData[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'NodeData'.
    Type 'Partial<NodeData>' is not assignable to type 'NodeData'.
      Property 'id' is optional in type 'Partial<NodeData>' but required in type 'NodeData'.

305         nodes: nodeDiff.enter,
            ~~~~~

  node_modules/@antv/g6/src/spec/data.ts:35:3
    35   nodes?: NodeData[];
         ~~~~~
    The expected type comes from property 'nodes' which is declared here on type 'GraphData'

node_modules/@antv/g6/src/runtime/data.ts:306:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'EdgeData[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'EdgeData'.
    Type 'Partial<NodeData>' is missing the following properties from type 'EdgeData': source, target

306         edges: edgeDiff.enter,
            ~~~~~

  node_modules/@antv/g6/src/spec/data.ts:41:3
    41   edges?: EdgeData[];
         ~~~~~
    The expected type comes from property 'edges' which is declared here on type 'GraphData'

node_modules/@antv/g6/src/runtime/data.ts:307:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'ComboData[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'ComboData'.
    Type 'Partial<NodeData>' is not assignable to type 'ComboData'.
      Property 'id' is optional in type 'Partial<NodeData>' but required in type 'ComboData'.

307         combos: comboDiff.enter,
            ~~~~~~

  node_modules/@antv/g6/src/spec/data.ts:47:3
    47   combos?: ComboData[];
         ~~~~~~
    The expected type comes from property 'combos' which is declared here on type 'GraphData'

node_modules/@antv/g6/src/runtime/data.ts:311:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'PartialNodeLikeData<NodeData>[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'PartialNodeLikeData<NodeData>'.
    Type 'Partial<NodeData>' is not assignable to type 'PartialNodeLikeData<NodeData>'.
      Type 'Partial<NodeData>' is not assignable to type 'Pick<NodeData, "id">'.
        Property 'id' is optional in type 'Partial<NodeData>' but required in type 'Pick<NodeData, "id">'.

311         nodes: nodeDiff.update,
            ~~~~~

  node_modules/@antv/g6/src/types/data.ts:50:3
    50   nodes?: PartialNodeLikeData<NodeData>[];
         ~~~~~
    The expected type comes from property 'nodes' which is declared here on type 'PartialGraphData'

node_modules/@antv/g6/src/runtime/data.ts:312:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'PartialEdgeData<EdgeData>[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'PartialEdgeData<EdgeData>'.
    Type 'Partial<NodeData>' is not assignable to type 'PartialEdgeData<EdgeData>'.
      Type 'Partial<NodeData>' is not assignable to type 'Partial<EdgeData> & Pick<EdgeData, "id">'.
        Type 'Partial<NodeData>' is not assignable to type 'Partial<EdgeData>'.
          The types of 'style.labelPlacement' are incompatible between these types.
            Type 'DirectionalPlacement' is not assignable to type 'number | "center" | "start" | "end"'.
              Type '"left"' is not assignable to type 'number | "center" | "start" | "end"'.

312         edges: edgeDiff.update,
            ~~~~~

  node_modules/@antv/g6/src/types/data.ts:51:3
    51   edges?: PartialEdgeData<EdgeData>[];
         ~~~~~
    The expected type comes from property 'edges' which is declared here on type 'PartialGraphData'

node_modules/@antv/g6/src/runtime/data.ts:313:9 - error TS2322: Type 'Partial<ElementDatum>[]' is not assignable to type 'PartialNodeLikeData<ComboData>[]'.
  Type 'Partial<ElementDatum>' is not assignable to type 'PartialNodeLikeData<ComboData>'.
    Type 'Partial<NodeData>' is not assignable to type 'PartialNodeLikeData<ComboData>'.
      Type 'Partial<NodeData>' is not assignable to type 'Pick<ComboData, "id">'.
        Property 'id' is optional in type 'Partial<NodeData>' but required in type 'Pick<ComboData, "id">'.

313         combos: comboDiff.update,
            ~~~~~~

  node_modules/@antv/g6/src/types/data.ts:52:3
    52   combos?: PartialNodeLikeData<ComboData>[];
         ~~~~~~
    The expected type comes from property 'combos' which is declared here on type 'PartialGraphData'

node_modules/@antv/g6/src/runtime/element.ts:83:5 - error TS2578: Unused '@ts-expect-error' directive.

83     // @ts-expect-error skip type check
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@antv/g6/src/utils/tree.ts:23:35 - error TS2352: Conversion of type 'TreeData' to type 'NodeData' may be a mistake because neither type sufficiently overlaps with the o
ther. If this was intentional, convert the expression to 'unknown' first.
  Types of property 'children' are incompatible.
    Type 'TreeData[]' is not comparable to type 'string[]'.
      Type 'TreeData' is not comparable to type 'string'.

23       if (!datum.children) return datum as NodeData;
                                     ~~~~~~~~~~~~~~~~~


Found 14 errors.


Process finished with exit code 2

posted by Aarebecca 6 months ago

Fund this Issue

$0.00
Funded

Pull requests