tsu
tsu copied to clipboard
Some number parameters/properties get truncated
Due to JavaScript/TypeScript not really having a notion of an integer (outside of the recently added BigInt
) it becomes a problem when you have functions like UKismetMathLibrary::Clamp
, which only clamps int32
.
This then shows up in the typings as:
static clamp(value: number, min: number, max: number): number;
... which looks harmless but will in fact truncate any decimals that gets sent into it. Outside of looking at the actual C++ declaration of the target function there is no way of knowing if something will truncate or not.
I'm not sure how to fix this, but one alternative would be to at least emit some kind of documentation, like:
/**
* @param value Warning: Integer parameter, will truncate
* @param min Warning: Integer parameter, will truncate
* @param max Warning: Integer parameter, will truncate
*/
static clamp(value: number, min: number, max: number): number;