dukat
dukat copied to clipboard
Failing to translate correctly varargs in lambdas
Consider following declaration:
declare function ping(func: (...str: Array<string>) => boolean)
which is translated to:
external fun ping(func: (str: Array<String>) -> Boolean)
Which contradicts to what typescript code was purposed to. Unfortunately it's hard to think of workaround right now since we don't have varargs in lambdas.
This goes for normal arrays too:
consoleCommand: (name: string, ...args: string[]) => void;
makes
var consoleCommand: (name: String, args: String) -> Unit
Which is totally wrong. From here: https://github.com/altmp/altv-types/blob/master/client/index.d.ts#L68
We were able get the rest parameters as an array like the following:
val args: Array<String> = js("Array.prototype.slice.call(arguments, 1);")