I have this pretty simple code in TypeScript:
type SomeType = [number, number, number]; // Should be an array of exactly 3 numbers
interface IThing {
someThing: SomeType
}
abstract class SomeClass {
abstract getThing(): IThing;
}
class ConcreteClass extends SomeClass {
getThing() {
return {
someThing: [4, 2, 2];
}
}
}
In the concrete class, when I assign someThing to [4, 2, 2], Typescript complains that Type number[] is not assignable to type [number, number, number]. Why is this, and how else can I ensure that someThing is an array of only 3 numbers?