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".
- is diagnosis correct?
- 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
Post a Comment