I have following interface:
interface Point<T> {
x: T;
y: T;
}
Now I want to have an array of points:
let points = [
{ x: 1, y: 1 }, // this is ok
{ x: "a", y: "b" }, // also ok
{ x: 1, y: "str" }, // should be an error
];
What type would I give to the points
variable? The only one I can think of is (Point<number> | Point<string>)[]
, but what if the types are not known ahead of time?