TS2345 and TS2339 errors are thrown for simple code in Angular











up vote
1
down vote

favorite












I am trying to learn to use D3 with angular. As a beginner I am trying to implement a simple project written by William Liu a few years ago (http://bl.ocks.org/WilliamQLiu/76ae20060e19bf42d774)
I could replicate most of the code but get compilation errors as below :




error TS2345: Argument of type 'BaseType' is not assignable to parameter of type 'ContainerElement'.
Type 'Element' is not assignable to type 'ContainerElement'.
Type 'Element' is not assignable to type 'SVGGElement'.
Property 'farthestViewportElement' is missing in type 'Element'.



error TS2339: Property 'dataset' does not exist on type 'BaseType'.
Property 'dataset' does not exist on type 'Element'.



error TS2339: Property 'dataset' does not exist on type 'BaseType'.
Property 'dataset' does not exist on type 'Element'.




I have created a component called dragex. The code is as below



import { Component, OnInit } from '@angular/core';
import * as d3 from 'd3';


@Component({
selector: 'dragex',
templateUrl: './dragex.component.html',
styleUrls: ['./dragex.component.css']
})
export class DragexComponent implements OnInit {
private dataset = [
{ x: 100, y: 110 },
{ x: 83, y: 43 },
{ x: 92, y: 28 },
{ x: 49, y: 74 },
{ x: 51, y: 10 },
{ x: 25, y: 98 },
{ x: 77, y: 30 },
{ x: 20, y: 83 },
{ x: 11, y: 63 },
{ x: 4, y: 55 },
{ x: 0, y: 0 },
{ x: 85, y: 100 },
{ x: 60, y: 40 },
{ x: 70, y: 80 },
{ x: 10, y: 20 },
{ x: 40, y: 50 },
{ x: 25, y: 31 }
];

constructor() { }

ngOnInit() {
this.drawchart();
}

private drawchart() {
const margin = {
top: 40,
right: 20,
bottom: 20,
left: 40
},
width = 960, // window.innerWidth,
height = 500, // window.innerHeight,
radius = 6;

let svg = d3.select('body').append('svg')
.attr('width', width )
.attr('height', height);

let xScale = d3.scaleLinear()
.domain([0, d3.max(this.dataset, function(d) { return d.x + 10; })])
.range([margin.left, width - margin.right]);

let yScale = d3.scaleLinear()
.domain([0, d3.max(this.dataset, function(d) { return d.y + 10; })])
.range([margin.top, width - margin.bottom]);

let xAxis = d3.axisTop(xScale);
let yAxis = d3.axisLeft(yScale);

let circleAttrs = {
cx: function(d) { return xScale(d.x); },
cy: function(d) { return yScale(d.y); },
r: radius
} ;

svg.append('g')
.attr('class', 'axis')
.attr( 'transform', 'translate(' + [margin.left, 0] + ')')
.call(yAxis);

svg.selectAll('circle')
.data(this.dataset)
.enter().append('circle')
.attr('cx', circleAttrs.cx)
.attr('cy', circleAttrs.cy)
.attr('r', circleAttrs.r)
.on('mouseover', handleMouseOver)
.on('mouseout', handleMouseOut);

svg.on('click', function() {
let coords = d3.mouse(this);

let newData = {
x: Math.round(xScale.invert(coords[0])),
y: Math.round(yScale.invert(coords[1]))
};


this.dataset.push(newData);


svg.selectAll('circle')
.data(this.dataset)
.enter().append('circle')
.attr('cx', circleAttrs.cx)
.attr('cy', circleAttrs.cy)
.attr('r', circleAttrs.r)
.on('mouseover', handleMouseOver)
.on('mouseout', handleMouseOut);

});




function handleMouseOver(d, i) {
d3.select(this)
.attr('fill', 'green')
.attr('r', radius * 2 );

svg.append('text')
.attr('id', 't' + d.x + '-' + d.y + '-' + i)
.attr('x', function() { return xScale(d.x) - 30 ; })
.attr('y', function() { return yScale(d.y) - 15 ; })
.text(d.x + ',' + d.y );

}

function handleMouseOut(d, i) {
d3.select(this)
.attr('fill', 'black')
.attr( 'r', radius);

d3.select('id').remove();
}
}
}


The errors are thrown on
let coords = d3.mouse(this);
this.dataset.push(newData);
.data(this.dataset)



The plunker for the same is available at
https://plnkr.co/edit/pM5ZsVw7EOm4bMI94JKj?p=info



On hovering over this in the above lines it shows d3.BaseType whereas ideally it should show this: this



I have had a look at other articles but none of them is pointing at the same solution.



Help!



===========================================================================



I shifted out the functions in that code into a new function (as below) and the errors go away.
Just have a DOM error now that shows this.dataset.push is not a function.



function onClickIn(d, i) {
let coords = d3.mouse(this);
console.log('here in onclick function');

let newData = {
x: Math.round(xScale.invert(coords[0])),
y: Math.round(yScale.invert(coords[1]))
};

console.log('new point- x:'+ newData.x + ',' + newData.y);
this.dataset.push(newData);

svg.select('circle')
.data(this.dataset)
.enter().append('circle')
.attr('cx', circleAttrs.cx)
.attr('cy', circleAttrs.cy)
.attr('r', circleAttrs.r)
.on('mouseover', handleMouseOver)
.on('mouseout', handleMouseOut);
}









share|improve this question




























    up vote
    1
    down vote

    favorite












    I am trying to learn to use D3 with angular. As a beginner I am trying to implement a simple project written by William Liu a few years ago (http://bl.ocks.org/WilliamQLiu/76ae20060e19bf42d774)
    I could replicate most of the code but get compilation errors as below :




    error TS2345: Argument of type 'BaseType' is not assignable to parameter of type 'ContainerElement'.
    Type 'Element' is not assignable to type 'ContainerElement'.
    Type 'Element' is not assignable to type 'SVGGElement'.
    Property 'farthestViewportElement' is missing in type 'Element'.



    error TS2339: Property 'dataset' does not exist on type 'BaseType'.
    Property 'dataset' does not exist on type 'Element'.



    error TS2339: Property 'dataset' does not exist on type 'BaseType'.
    Property 'dataset' does not exist on type 'Element'.




    I have created a component called dragex. The code is as below



    import { Component, OnInit } from '@angular/core';
    import * as d3 from 'd3';


    @Component({
    selector: 'dragex',
    templateUrl: './dragex.component.html',
    styleUrls: ['./dragex.component.css']
    })
    export class DragexComponent implements OnInit {
    private dataset = [
    { x: 100, y: 110 },
    { x: 83, y: 43 },
    { x: 92, y: 28 },
    { x: 49, y: 74 },
    { x: 51, y: 10 },
    { x: 25, y: 98 },
    { x: 77, y: 30 },
    { x: 20, y: 83 },
    { x: 11, y: 63 },
    { x: 4, y: 55 },
    { x: 0, y: 0 },
    { x: 85, y: 100 },
    { x: 60, y: 40 },
    { x: 70, y: 80 },
    { x: 10, y: 20 },
    { x: 40, y: 50 },
    { x: 25, y: 31 }
    ];

    constructor() { }

    ngOnInit() {
    this.drawchart();
    }

    private drawchart() {
    const margin = {
    top: 40,
    right: 20,
    bottom: 20,
    left: 40
    },
    width = 960, // window.innerWidth,
    height = 500, // window.innerHeight,
    radius = 6;

    let svg = d3.select('body').append('svg')
    .attr('width', width )
    .attr('height', height);

    let xScale = d3.scaleLinear()
    .domain([0, d3.max(this.dataset, function(d) { return d.x + 10; })])
    .range([margin.left, width - margin.right]);

    let yScale = d3.scaleLinear()
    .domain([0, d3.max(this.dataset, function(d) { return d.y + 10; })])
    .range([margin.top, width - margin.bottom]);

    let xAxis = d3.axisTop(xScale);
    let yAxis = d3.axisLeft(yScale);

    let circleAttrs = {
    cx: function(d) { return xScale(d.x); },
    cy: function(d) { return yScale(d.y); },
    r: radius
    } ;

    svg.append('g')
    .attr('class', 'axis')
    .attr( 'transform', 'translate(' + [margin.left, 0] + ')')
    .call(yAxis);

    svg.selectAll('circle')
    .data(this.dataset)
    .enter().append('circle')
    .attr('cx', circleAttrs.cx)
    .attr('cy', circleAttrs.cy)
    .attr('r', circleAttrs.r)
    .on('mouseover', handleMouseOver)
    .on('mouseout', handleMouseOut);

    svg.on('click', function() {
    let coords = d3.mouse(this);

    let newData = {
    x: Math.round(xScale.invert(coords[0])),
    y: Math.round(yScale.invert(coords[1]))
    };


    this.dataset.push(newData);


    svg.selectAll('circle')
    .data(this.dataset)
    .enter().append('circle')
    .attr('cx', circleAttrs.cx)
    .attr('cy', circleAttrs.cy)
    .attr('r', circleAttrs.r)
    .on('mouseover', handleMouseOver)
    .on('mouseout', handleMouseOut);

    });




    function handleMouseOver(d, i) {
    d3.select(this)
    .attr('fill', 'green')
    .attr('r', radius * 2 );

    svg.append('text')
    .attr('id', 't' + d.x + '-' + d.y + '-' + i)
    .attr('x', function() { return xScale(d.x) - 30 ; })
    .attr('y', function() { return yScale(d.y) - 15 ; })
    .text(d.x + ',' + d.y );

    }

    function handleMouseOut(d, i) {
    d3.select(this)
    .attr('fill', 'black')
    .attr( 'r', radius);

    d3.select('id').remove();
    }
    }
    }


    The errors are thrown on
    let coords = d3.mouse(this);
    this.dataset.push(newData);
    .data(this.dataset)



    The plunker for the same is available at
    https://plnkr.co/edit/pM5ZsVw7EOm4bMI94JKj?p=info



    On hovering over this in the above lines it shows d3.BaseType whereas ideally it should show this: this



    I have had a look at other articles but none of them is pointing at the same solution.



    Help!



    ===========================================================================



    I shifted out the functions in that code into a new function (as below) and the errors go away.
    Just have a DOM error now that shows this.dataset.push is not a function.



    function onClickIn(d, i) {
    let coords = d3.mouse(this);
    console.log('here in onclick function');

    let newData = {
    x: Math.round(xScale.invert(coords[0])),
    y: Math.round(yScale.invert(coords[1]))
    };

    console.log('new point- x:'+ newData.x + ',' + newData.y);
    this.dataset.push(newData);

    svg.select('circle')
    .data(this.dataset)
    .enter().append('circle')
    .attr('cx', circleAttrs.cx)
    .attr('cy', circleAttrs.cy)
    .attr('r', circleAttrs.r)
    .on('mouseover', handleMouseOver)
    .on('mouseout', handleMouseOut);
    }









    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to learn to use D3 with angular. As a beginner I am trying to implement a simple project written by William Liu a few years ago (http://bl.ocks.org/WilliamQLiu/76ae20060e19bf42d774)
      I could replicate most of the code but get compilation errors as below :




      error TS2345: Argument of type 'BaseType' is not assignable to parameter of type 'ContainerElement'.
      Type 'Element' is not assignable to type 'ContainerElement'.
      Type 'Element' is not assignable to type 'SVGGElement'.
      Property 'farthestViewportElement' is missing in type 'Element'.



      error TS2339: Property 'dataset' does not exist on type 'BaseType'.
      Property 'dataset' does not exist on type 'Element'.



      error TS2339: Property 'dataset' does not exist on type 'BaseType'.
      Property 'dataset' does not exist on type 'Element'.




      I have created a component called dragex. The code is as below



      import { Component, OnInit } from '@angular/core';
      import * as d3 from 'd3';


      @Component({
      selector: 'dragex',
      templateUrl: './dragex.component.html',
      styleUrls: ['./dragex.component.css']
      })
      export class DragexComponent implements OnInit {
      private dataset = [
      { x: 100, y: 110 },
      { x: 83, y: 43 },
      { x: 92, y: 28 },
      { x: 49, y: 74 },
      { x: 51, y: 10 },
      { x: 25, y: 98 },
      { x: 77, y: 30 },
      { x: 20, y: 83 },
      { x: 11, y: 63 },
      { x: 4, y: 55 },
      { x: 0, y: 0 },
      { x: 85, y: 100 },
      { x: 60, y: 40 },
      { x: 70, y: 80 },
      { x: 10, y: 20 },
      { x: 40, y: 50 },
      { x: 25, y: 31 }
      ];

      constructor() { }

      ngOnInit() {
      this.drawchart();
      }

      private drawchart() {
      const margin = {
      top: 40,
      right: 20,
      bottom: 20,
      left: 40
      },
      width = 960, // window.innerWidth,
      height = 500, // window.innerHeight,
      radius = 6;

      let svg = d3.select('body').append('svg')
      .attr('width', width )
      .attr('height', height);

      let xScale = d3.scaleLinear()
      .domain([0, d3.max(this.dataset, function(d) { return d.x + 10; })])
      .range([margin.left, width - margin.right]);

      let yScale = d3.scaleLinear()
      .domain([0, d3.max(this.dataset, function(d) { return d.y + 10; })])
      .range([margin.top, width - margin.bottom]);

      let xAxis = d3.axisTop(xScale);
      let yAxis = d3.axisLeft(yScale);

      let circleAttrs = {
      cx: function(d) { return xScale(d.x); },
      cy: function(d) { return yScale(d.y); },
      r: radius
      } ;

      svg.append('g')
      .attr('class', 'axis')
      .attr( 'transform', 'translate(' + [margin.left, 0] + ')')
      .call(yAxis);

      svg.selectAll('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);

      svg.on('click', function() {
      let coords = d3.mouse(this);

      let newData = {
      x: Math.round(xScale.invert(coords[0])),
      y: Math.round(yScale.invert(coords[1]))
      };


      this.dataset.push(newData);


      svg.selectAll('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);

      });




      function handleMouseOver(d, i) {
      d3.select(this)
      .attr('fill', 'green')
      .attr('r', radius * 2 );

      svg.append('text')
      .attr('id', 't' + d.x + '-' + d.y + '-' + i)
      .attr('x', function() { return xScale(d.x) - 30 ; })
      .attr('y', function() { return yScale(d.y) - 15 ; })
      .text(d.x + ',' + d.y );

      }

      function handleMouseOut(d, i) {
      d3.select(this)
      .attr('fill', 'black')
      .attr( 'r', radius);

      d3.select('id').remove();
      }
      }
      }


      The errors are thrown on
      let coords = d3.mouse(this);
      this.dataset.push(newData);
      .data(this.dataset)



      The plunker for the same is available at
      https://plnkr.co/edit/pM5ZsVw7EOm4bMI94JKj?p=info



      On hovering over this in the above lines it shows d3.BaseType whereas ideally it should show this: this



      I have had a look at other articles but none of them is pointing at the same solution.



      Help!



      ===========================================================================



      I shifted out the functions in that code into a new function (as below) and the errors go away.
      Just have a DOM error now that shows this.dataset.push is not a function.



      function onClickIn(d, i) {
      let coords = d3.mouse(this);
      console.log('here in onclick function');

      let newData = {
      x: Math.round(xScale.invert(coords[0])),
      y: Math.round(yScale.invert(coords[1]))
      };

      console.log('new point- x:'+ newData.x + ',' + newData.y);
      this.dataset.push(newData);

      svg.select('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);
      }









      share|improve this question















      I am trying to learn to use D3 with angular. As a beginner I am trying to implement a simple project written by William Liu a few years ago (http://bl.ocks.org/WilliamQLiu/76ae20060e19bf42d774)
      I could replicate most of the code but get compilation errors as below :




      error TS2345: Argument of type 'BaseType' is not assignable to parameter of type 'ContainerElement'.
      Type 'Element' is not assignable to type 'ContainerElement'.
      Type 'Element' is not assignable to type 'SVGGElement'.
      Property 'farthestViewportElement' is missing in type 'Element'.



      error TS2339: Property 'dataset' does not exist on type 'BaseType'.
      Property 'dataset' does not exist on type 'Element'.



      error TS2339: Property 'dataset' does not exist on type 'BaseType'.
      Property 'dataset' does not exist on type 'Element'.




      I have created a component called dragex. The code is as below



      import { Component, OnInit } from '@angular/core';
      import * as d3 from 'd3';


      @Component({
      selector: 'dragex',
      templateUrl: './dragex.component.html',
      styleUrls: ['./dragex.component.css']
      })
      export class DragexComponent implements OnInit {
      private dataset = [
      { x: 100, y: 110 },
      { x: 83, y: 43 },
      { x: 92, y: 28 },
      { x: 49, y: 74 },
      { x: 51, y: 10 },
      { x: 25, y: 98 },
      { x: 77, y: 30 },
      { x: 20, y: 83 },
      { x: 11, y: 63 },
      { x: 4, y: 55 },
      { x: 0, y: 0 },
      { x: 85, y: 100 },
      { x: 60, y: 40 },
      { x: 70, y: 80 },
      { x: 10, y: 20 },
      { x: 40, y: 50 },
      { x: 25, y: 31 }
      ];

      constructor() { }

      ngOnInit() {
      this.drawchart();
      }

      private drawchart() {
      const margin = {
      top: 40,
      right: 20,
      bottom: 20,
      left: 40
      },
      width = 960, // window.innerWidth,
      height = 500, // window.innerHeight,
      radius = 6;

      let svg = d3.select('body').append('svg')
      .attr('width', width )
      .attr('height', height);

      let xScale = d3.scaleLinear()
      .domain([0, d3.max(this.dataset, function(d) { return d.x + 10; })])
      .range([margin.left, width - margin.right]);

      let yScale = d3.scaleLinear()
      .domain([0, d3.max(this.dataset, function(d) { return d.y + 10; })])
      .range([margin.top, width - margin.bottom]);

      let xAxis = d3.axisTop(xScale);
      let yAxis = d3.axisLeft(yScale);

      let circleAttrs = {
      cx: function(d) { return xScale(d.x); },
      cy: function(d) { return yScale(d.y); },
      r: radius
      } ;

      svg.append('g')
      .attr('class', 'axis')
      .attr( 'transform', 'translate(' + [margin.left, 0] + ')')
      .call(yAxis);

      svg.selectAll('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);

      svg.on('click', function() {
      let coords = d3.mouse(this);

      let newData = {
      x: Math.round(xScale.invert(coords[0])),
      y: Math.round(yScale.invert(coords[1]))
      };


      this.dataset.push(newData);


      svg.selectAll('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);

      });




      function handleMouseOver(d, i) {
      d3.select(this)
      .attr('fill', 'green')
      .attr('r', radius * 2 );

      svg.append('text')
      .attr('id', 't' + d.x + '-' + d.y + '-' + i)
      .attr('x', function() { return xScale(d.x) - 30 ; })
      .attr('y', function() { return yScale(d.y) - 15 ; })
      .text(d.x + ',' + d.y );

      }

      function handleMouseOut(d, i) {
      d3.select(this)
      .attr('fill', 'black')
      .attr( 'r', radius);

      d3.select('id').remove();
      }
      }
      }


      The errors are thrown on
      let coords = d3.mouse(this);
      this.dataset.push(newData);
      .data(this.dataset)



      The plunker for the same is available at
      https://plnkr.co/edit/pM5ZsVw7EOm4bMI94JKj?p=info



      On hovering over this in the above lines it shows d3.BaseType whereas ideally it should show this: this



      I have had a look at other articles but none of them is pointing at the same solution.



      Help!



      ===========================================================================



      I shifted out the functions in that code into a new function (as below) and the errors go away.
      Just have a DOM error now that shows this.dataset.push is not a function.



      function onClickIn(d, i) {
      let coords = d3.mouse(this);
      console.log('here in onclick function');

      let newData = {
      x: Math.round(xScale.invert(coords[0])),
      y: Math.round(yScale.invert(coords[1]))
      };

      console.log('new point- x:'+ newData.x + ',' + newData.y);
      this.dataset.push(newData);

      svg.select('circle')
      .data(this.dataset)
      .enter().append('circle')
      .attr('cx', circleAttrs.cx)
      .attr('cy', circleAttrs.cy)
      .attr('r', circleAttrs.r)
      .on('mouseover', handleMouseOver)
      .on('mouseout', handleMouseOut);
      }






      angular d3.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 16:15

























      asked Mar 22 at 15:04









      Krishnan Iyer

      63




      63
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Try replacing:



          let coords = d3.mouse(this);


          For



          let aux:any = this
          let coords = d3.mouse(aux);


          This way you fool the Typescript Compiler.






          share|improve this answer




























            up vote
            0
            down vote













            Use type assertion



            const coords = d3.mouse(this as SVGGElement);





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49432032%2fts2345-and-ts2339-errors-are-thrown-for-simple-code-in-angular%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              Try replacing:



              let coords = d3.mouse(this);


              For



              let aux:any = this
              let coords = d3.mouse(aux);


              This way you fool the Typescript Compiler.






              share|improve this answer

























                up vote
                0
                down vote













                Try replacing:



                let coords = d3.mouse(this);


                For



                let aux:any = this
                let coords = d3.mouse(aux);


                This way you fool the Typescript Compiler.






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Try replacing:



                  let coords = d3.mouse(this);


                  For



                  let aux:any = this
                  let coords = d3.mouse(aux);


                  This way you fool the Typescript Compiler.






                  share|improve this answer












                  Try replacing:



                  let coords = d3.mouse(this);


                  For



                  let aux:any = this
                  let coords = d3.mouse(aux);


                  This way you fool the Typescript Compiler.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 20 at 15:41









                  Esteve Tarragó

                  1




                  1
























                      up vote
                      0
                      down vote













                      Use type assertion



                      const coords = d3.mouse(this as SVGGElement);





                      share|improve this answer

























                        up vote
                        0
                        down vote













                        Use type assertion



                        const coords = d3.mouse(this as SVGGElement);





                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Use type assertion



                          const coords = d3.mouse(this as SVGGElement);





                          share|improve this answer












                          Use type assertion



                          const coords = d3.mouse(this as SVGGElement);






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 3 hours ago









                          Ekaterina Tokareva

                          43635




                          43635






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49432032%2fts2345-and-ts2339-errors-are-thrown-for-simple-code-in-angular%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Tonle Sap (See)

                              I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

                              Guatemaltekische Davis-Cup-Mannschaft