Currently delving into the world of JavaScript, I come from a background of working with statically typed languages. Naturally, I opted to dive into TypeScript instead of starting directly with JS. While TypeScript is great and addresses many issues present in JS, the concept of "weak typing" really bothers me.
It just doesn't sit right with me that I can do something like this:
let int: number = 42
let str: string = "69"
console.log(int + str)
Is there a way in TypeScript to prevent these type conversions from happening? I would prefer to receive an error when trying to add a string
to an integer
.