This is my code in TypeScript:
const num1 = 10;
const num2 = 20;
if(num1===num2){
console.log("true")
}
This is giving me error: enter image description here
Error: This comparison appears to be unintentional because the types ’10’ and ’20’ have no overlap.
If i am assigning number to these variables like this:
const num1:number = 10;
const num2:number = 20;
then this is running fine, I am learning typescript, so kindly explain me why is the first code without giving types to variables is giving me error?
Also, if i am declaring variables with let , its running fine.