Typescript type error doesn't make sense -


interface   {     x:string; y:string   };  var a: a[] = []; a.push(   {x: "a",     y: "b"});  a.slice(-1).x = "foo"; 

that last line gets error think because result of a.slice(-1) not of known type, says "no known property x".

  1. is diagnosis correct?
  2. what's right way that?

thanks!

the problem a.slice(-1) returns array (the slice) though has 1 element. array not have "x" property. each element does.

so following expected:

a.slice(-1)[0].x = "foo"; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -