Typescript definition for settings points on a link

I try to set some points on a link as described in the documentation:

The setter also accepts an Array of alternating X,Y point values [1, 2, 3, 4, 5, 6], or an Array of Objects each of which has (lowercase) ‘x’ and ‘y’ properties that are numbers [{“x”:1,“y”:2}, {“x”:3,“y”:4}, {“x”:5,“y”:6}].

link.points = [4, 5, 122, 44, 333, 44];

However, this doesn’t work:
Type 'number[]' is missing the following properties from type 'List<Point>': add, addAll, clear, contains, and 23 more.

I think the TypeScript definition could be improved here, couldn’t it?

That points out a problem with TypeScript that some other typed languages do not have. The problem is that the property getter will always return List<Point>, so it is handy to declare it that way so that you can write expressions such as someLink.points.first() or other code expecting a List.

But the property setter is able to handle additional types, as you should have found out when running that compiled code. So you are going to have to cast the Array to a List<Point> via any. Sorry. If you have a better idea, I’m open to suggestions.

I see… thanks for the explanation, I wasn’t aware of that.