typescript - No se puede usar @types/d3-tip: El argumento de tipo 'Tooltip' no es asignable
Estoy usando @types/d3-tip con d3 de la siguiente manera:
self.tooltip = d3.tip()
.attr('class', 'tooltip')
.offset([-10,0])
.html(function(d: Datapoint) {
...
})
self.svg.call(self.tooltip)
Esto genera un 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'
¿Qué estoy haciendo mal?
Respuesta #1
Intenta usar la palabra clave as para superar el error del verificador de tipos así:
self.svg.call(self.tooltip as any)
Este enfoque puede ser controvertido según esta discusión, pero te permitirá superar el error.
