The functionality of the JavaScript function parseInt
allows for the coercion of a specified parameter into an integer, regardless of whether that parameter is originally a string, float number, or another type.
While in JavaScript, performing parseInt(1.2)
results in 1
without any issues, TypeScript throws an error during compilation:
error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
I'm curious if this behavior from TypeScript is intentional or if there might be something I am overlooking. Any insights?