Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 类型';选择<;SVGElement>';与'型不可比;选择<;SVGSVGElement>';_Typescript_D3.js_Svg - Fatal编程技术网

Typescript 类型';选择<;SVGElement>';与'型不可比;选择<;SVGSVGElement>';

Typescript 类型';选择<;SVGElement>';与'型不可比;选择<;SVGSVGElement>';,typescript,d3.js,svg,Typescript,D3.js,Svg,我对类型脚本和泛型相当陌生,我正在努力解决一个编译器问题。当我运行下面的代码(编译目标GitHub项目)时,我得到了标题错误 我已尝试将d3的类型转换更改为。选择更改为。我已尝试将d3的类型转换更改为。选择在审阅后,我必须撤回我的评论。将其更改为SVGSVGElement实际上纠正了这个问题。我把它和另一个与缺少类型相关的编译器错误混淆了。 import * as d3 from 'd3'; type D3SVGSelection = d3.Selection<SVGElement, a

我对类型脚本和泛型相当陌生,我正在努力解决一个编译器问题。当我运行下面的代码(编译目标GitHub项目)时,我得到了标题错误


我已尝试将d3的类型转换更改为。选择更改为
。我已尝试将d3的类型转换更改为。选择在审阅后,我必须撤回我的评论。将其更改为
SVGSVGElement
实际上纠正了这个问题。我把它和另一个与缺少类型相关的编译器错误混淆了。
import * as d3 from 'd3';

type D3SVGSelection = d3.Selection<SVGElement, any, null, undefined>;
constructor(elm: HTMLDivElement) {
    private svg: D3SVGSelection;

    this.svg = (d3.select(elm).append('svg') as D3SVGSelection)
               .attr('viewBox', '-5 5 130 110')
               .attr('style', 'width: 95%; height: 70%; margin-left:5px');