Currently, I'm learning TypeScript and I came across a code snippet that is causing some confusion.
var str = '1'
var str2:number = <number> <any> str //str is now of type number
console.log(typeof(str2))
log: String
From my understanding, initially str was inferred as a String, then it was asserted to be a number when assigned to str2. Str2 was explicitly defined as a number. So why are both str and str2 not of type number since one is converted to a number and the other is declared as a number?