Skip to content

Some generated types are invalid: CellArray and Layouts #96

Closed

Description

@tbouffard

Some generated types seem invalid. When using them in an external project, the tsconfig must be set to skipLibCheck: true
Involved types (see the errors at the end of the description)

I have detected the issue in #87 (comment)

> @maxgraph/ts-example-built-with-vite@0.0.0 build
> tsc && vite build

../core/dist/types/view/cell/CellArray.d.ts:4:5 - error TS2416: Property 'concat' in type 'CellArray' is not assignable to the same property in base type 'Cell[]'.
  Type '(items: any) => CellArray' is not assignable to type '{ (...items: ConcatArray<Cell>[]): Cell[]; (...items: (Cell | ConcatArray<Cell>)[]): Cell[]; }'.
    Call signature return types 'CellArray' and 'Cell[]' are incompatible.
      The types returned by 'map(...).pop()' are incompatible between these types.
        Type 'Cell | undefined' is not assignable to type 'U | undefined'.
          Type 'Cell' is not assignable to type 'U'.
            'U' could be instantiated with an arbitrary type which could be unrelated to 'Cell'.

4     concat(items: any): CellArray;
      ~~~~~~

../core/dist/types/view/cell/CellArray.d.ts:5:5 - error TS2416: Property 'splice' in type 'CellArray' is not assignable to the same property in base type 'Cell[]'.
  Type '(arg0: number, ...args: any) => CellArray' is not assignable to type '{ (start: number, deleteCount?: number | undefined): Cell[]; (start: number, deleteCount: number, ...items: Cell[]): Cell[]; }'.
    Type 'CellArray' is not assignable to type 'Cell[]'.

5     splice(arg0: number, ...args: any): CellArray;
      ~~~~~~

../core/dist/types/view/cell/CellArray.d.ts:6:5 - error TS2416: Property 'slice' in type 'CellArray' is not assignable to the same property in base type 'Cell[]'.
  Type '(...args: any) => CellArray' is not assignable to type '(start?: number | undefined, end?: number | undefined) => Cell[]'.
    Type 'CellArray' is not assignable to type 'Cell[]'.

6     slice(...args: any): CellArray;
      ~~~~~

../core/dist/types/view/cell/CellArray.d.ts:7:5 - error TS2416: Property 'map' in type 'CellArray' is not assignable to the same property in base type 'Cell[]'.
  Type '(arg0: any, ...args: any) => CellArray' is not assignable to type '<U>(callbackfn: (value: Cell, index: number, array: Cell[]) => U, thisArg?: any) => U[]'.
    Call signature return types 'CellArray' and 'U[]' are incompatible.
      The types returned by 'pop()' are incompatible between these types.
        Type 'Cell | undefined' is not assignable to type 'U | undefined'.
          Type 'Cell' is not assignable to type 'U'.
            'U' could be instantiated with an arbitrary type which could be unrelated to 'Cell'.

7     map(arg0: any, ...args: any): CellArray;
      ~~~

../core/dist/types/view/cell/CellArray.d.ts:8:5 - error TS2416: Property 'filter' in type 'CellArray' is not assignable to the same property in base type 'Cell[]'.
  Type '(arg0: any, ...args: any) => CellArray' is not assignable to type '{ <S extends Cell>(predicate: (value: Cell, index: number, array: Cell[]) => value is S, thisArg?: any): S[]; (predicate: (value: Cell, index: number, array: Cell[]) => unknown, thisArg?: any): Cell[]; }'.
    Call signature return types 'CellArray' and 'any[]' are incompatible.
      The types returned by 'map(...).pop()' are incompatible between these types.
        Type 'Cell | undefined' is not assignable to type 'U | undefined'.
          Type 'Cell' is not assignable to type 'U'.
            'U' could be instantiated with an arbitrary type which could be unrelated to 'Cell'.

8     filter(arg0: any, ...args: any): CellArray;
      ~~~~~~

../core/dist/types/view/layout/HierarchicalLayout.d.ts:203:5 - error TS2416: Property 'traverse' in type 'HierarchicalLayout' is not assignable to the same property in base type 'GraphLayout'.
  Type '(vertex: Cell, directed: boolean | undefined, edge: Cell | null | undefined, allVertices: { [key: string]: Cell; } | null | undefined, currentComp: { [key: string]: Cell | null; }, hierarchyVertices: GraphHierarchyNode[], filledVertexSet?: { ...; } | ... 1 more ... | undefined) => { ...; }' is not assignable to type '(vertex: Cell, directed?: boolean | undefined, func?: Function | undefined, edge?: Cell | undefined, visited?: Dictionary<Cell, boolean> | undefined) => void'.

203     traverse(vertex: Cell, directed: boolean | undefined, edge: Cell | null | undefined, allVertices: {
        ~~~~~~~~

../core/dist/types/view/layout/SwimlaneLayout.d.ts:220:5 - error TS2416: Property 'traverse' in type 'SwimlaneLayout' is not assignable to the same property in base type 'GraphLayout'.
  Type '(vertex: Cell | null | undefined, directed: boolean, edge: Cell | null, allVertices: { [key: string]: Cell; } | null | undefined, currentComp: { [key: string]: Cell; }, hierarchyVertices: GraphHierarchyNode[], filledVertexSet: { ...; } | ... 1 more ... | undefined, swimlaneIndex: number) => { ...; }' is not assignable to type '(vertex: Cell, directed?: boolean | undefined, func?: Function | undefined, edge?: Cell | undefined, visited?: Dictionary<Cell, boolean> | undefined) => void'.

220     traverse(vertex: Cell | null | undefined, directed: boolean, edge: Cell | null, allVertices: {

Activity

  1. added
    bug
    on Jul 5, 2022
  2. self-assigned this
    on Aug 14, 2022
  3. added 2 commits that reference this issue on Sep 17, 2022
  4. tbouffard commented on Nov 16, 2022

    @tbouffard
    MemberAuthor

    All types are fixed, so closing this issue.

  5. added this to the 0.1.0 milestone on Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions