user31415629
user31415629

Reputation: 1005

Cannot use @types/d3-tip: Argument of type 'Tooltip' is not assignable

I am using @types/d3-tip with d3 as follows:

self.tooltip = d3.tip()
  .attr('class', 'tooltip')
  .offset([-10,0])
  .html(function(d: Datapoint) {
    ...
  })

self.svg.call(self.tooltip)

This throws up an error:

error TS2345: Argument of type 'Tooltip' is not assignable to parameter of type '(sel: Selection<SVGElement>, ...args: any[]) => any'.
  Type 'Tooltip' provides no match for the signature '(sel: Selection<SVGElement>, ...args: any[]): any'

What am I doing wrong?

Upvotes: 2

Views: 311

Answers (1)

JAC
JAC

Reputation: 601

Try using the as keyword to overcome the type-checker error like this:

self.svg.call(self.tooltip as any)

This approach may be controversial based on this discussion but it will allow you to overcome the error.

Upvotes: 1

Related Questions