When define a const Array type, its Array.length type also be the constant value. However, type of Array.length - 1 is not the constant value because TypeScript does not support minus operation between const number types.
Thus, I hope TypeScript to support the simple arithmetic operations on the const number types.
type SomeNumber = 3;
type SomeOperatedNumber = 3 - 1; // NOT POSSIBLE
function main(): void
{
let someArray: [number, string, false] = [1, "something", false];
let length: 3 = someArray.length;
let lastIndex: number = someArray.length - 1; // not 2, but number
}
When define a const
Arraytype, itsArray.lengthtype also be the constant value. However, type ofArray.length - 1is not the constant value because TypeScript does not support minus operation between const number types.Thus, I hope TypeScript to support the simple arithmetic operations on the const number types.