magjac / d3-graphviz

Graphviz DOT rendering and animated transitions using D3
BSD 3-Clause "New" or "Revised" License
1.67k stars 103 forks source link

Transition type error in typescript #290

Closed dbuezas closed 11 months ago

dbuezas commented 11 months ago

I find no way of getting the type of the transition right. It does works fine, but this code base doesn't allow me to add @ts-ignore and the like.

What is the correct way?

    import { graphviz } from 'd3-graphviz';
    import { transition } from 'd3-transition';
    // [...]
    const t = transition('reload').duration(1000);
    const g = graphviz(ref.current, { useWorker: false });
    g.zoomScaleExtent([0.5, 10])
      .tweenShapes(true)
      .convertEqualSidedPolygons(false)
      .growEnteringEdges(true)
      .tweenPaths(true)
      .fade(true)
      .transition(
        t,  <-- type error here
      )
      .renderDot(props.dot);

Gets me this error

Argument of type 'Transition<BaseType, unknown, null, undefined>' is not assignable to parameter of type '() => string | Transition<BaseType, any, BaseType, any>'.
  Type 'Transition<BaseType, unknown, null, undefined>' provides no match for the signature '(): string | Transition<BaseType, any, BaseType, any>'.ts(2345)

Thanks!

dbuezas commented 11 months ago

BTW, this doesn't work either:

     .transition(
        () => transition('reload').duration(1000)
      )
magjac commented 11 months ago

This project doesn't support typescript types. I suggest you file an issue at wherever you got them from.