Typescript is a statically typed language that works compile-time and it eventually converts your code to pure Javascript. the code in your post will be converted to below js code:
var myTuple = [10, "Hello"];
console.log(myTuple[1]);
var myArray = [10, 20, "Hello"]; // notice how number[] is stripped away from your code
console.log(myArray[2]);
Since Javascript is a dynamically typed language, it has no issues with myArray. whereas in Typescript, you have specified before hand that myArray would be a number array type and TS being a statically typed language checks if the value assigned to myArray is indeed a number array or not, which in this case is not. so it raises the following error:
Type 'string' is not assignable to type 'number'.(2322)
tsconfig.jsontypescriptlang.org/play?#code/…myArray: number[]tsc index.tsthen it gives compile error. when i runtsc index.ts | node index.jsthen it works without having any issues :)