In TypeScript, you can define the types of variables to ensure type safety and catch errors at compile time. This means that if you declare a variable as a specific type, TypeScript will expect that variable to only hold values of that type.
In your case, you declared a variable as type number, but assigned it a string value. TypeScript should have caught this error at compile time and thrown a type error, indicating that you cannot assign a string to a variable of type number.
However, you're saying that TypeScript allowed the code to compile to JavaScript without any errors. This could happen if you're using the --noEmitOnError flag when compiling your TypeScript code, which will prevent TypeScript from emitting any JavaScript output if there are any type errors. If you're not using this flag, it's possible that there was some other issue in your configuration that caused TypeScript to skip the type checking step.
In any case, it's important to always ensure that your code is correctly typed and to use TypeScript's type checking features to catch errors early in the development process.