Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
548 stars 44 forks source link

Failing to translate correctly varargs in lambdas #319

Open Schahen opened 4 years ago

Schahen commented 4 years ago

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.

7Hazard commented 3 years ago

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

7Hazard commented 3 years ago

We were able get the rest parameters as an array like the following:

val args: Array<String> = js("Array.prototype.slice.call(arguments, 1);")