Closed uniquker closed 2 years ago
What is svg? It should be a d3 selection.
What is svg? It should be a d3 selection.
const svg = d3.select('svg')
use this code resolve it. const svg = d3.select('svg') function zoomed (event: any) { console.log(event) } const zoom = zoom().on('zoom', zoomed) as any svg.call(zoom)
typescript verison 4.3.5 d3 version 7.1.0 code:(selector: string): Selection<DescElement, unknown, HTMLElement, any>; (selector: null): Selection<null, undefined, HTMLElement, any>; (selector: ValueFn<...>): Selection<...>; }' is not assignable to type '{ (selector: string): Selection<DescElement, unknown, any, any>; (selector: null): Selection<null, undefined, any, any>; (selector: ValueFn<...>): Selection<...>; }'.
Types of parameters 'selector' and 'selector' are incompatible.
Types of parameters 'groups' and 'groups' are incompatible.
Type 'BaseType[] | ArrayLike' is not assignable to type 'Element[] | ArrayLike'.
Type 'BaseType[]' is not assignable to type 'Element[] | ArrayLike'.
Type 'BaseType[]' is not assignable to type 'Element[]'.
Type 'BaseType' is not assignable to type 'Element'.ts(2345)
svg.call(d3.zoom().on('zoom',function(){}))
typescript warning: Argument of type 'ZoomBehavior<Element, unknown>' is not assignable to parameter of type '(selection: Selection<BaseType, unknown, HTMLElement, any>, ...args: any[]) => void'. Types of parameters 'selection' and 'selection' are incompatible. Type 'Selection<BaseType, unknown, HTMLElement, any>' is not assignable to type 'Selection<Element, unknown, any, any>'. Types of property 'select' are incompatible. Type '{