2017-08-08 50 views
2

我正在使用@类型/ D3尖与D3如下:不能使用@类型/ D3-提示:类型的参数“工具提示”不能分配

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

self.svg.call(self.tooltip) 

这抛出了一个错误:

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' 

我在做什么错?

回答

0

尝试使用as关键字克服类型检查的错误是这样的:

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

这种方法可以基于this discussion是有争议的,但它可以让你克服错误。

相关问题