I'm changing my application from ActionScript to Javascript/TypeScript (because of Flash Player) and I came across a problem, the types of ActionScript automatically converts the number to the given type and I was wondering if this is possible with TypeScript.
Example:
function test(x: int, y: int){
console.log(x, y) //output: 1, 3
}
test(1.5, 3.7)
I know I can use the Math.trunc function for this, but imagine if I have several int parameters and variables:
function test(x: number, y: number, w: number, h: number){
x = Math.trunc(x)
y = Math.trunc(y)
w = Math.trunc(w)
h = Math.trunc(h)
other: number = 10;
x = Math.trunc(x / other)
}
Note: I'm having to use Math.trunc all the time to keep the integer value.
So this is possible with Javascript/TypeScript? If not, there are recommendations from other languages for me to migrate?