How do I fix my type hints?

There’s a solid red bar in the editor.

function debugWrap<T>(name: string, func: (player: Player, ...) -> (T)): (player: Player, ...) -> (T)

However, when replacing either of the ellipses with any, the red bar goes away.

function debugWrap<T>(name: string, func: (player: Player, any) -> (T)): (player: Player, ...) -> (T)

Typing it into the command bar, it tells me this is apparently an invalid type.

> function debugWrap<T>(name: string, func: (player: Player, ...) -> (T)): (player: Player, ...) -> (T) end  -  Studio
(...): Expected type, got ')'  -  Studio

I can’t replace the ellipses with another type parameter, because it would only then accept one argument.

The input function signature and the output function signature should be the same.

What is the correct way to add type hints to my code?

You’re expected to use ellipses with types like so: T... or ...T
In your case, it should be

function debugWrap<T>(name: string, func: (player: Player, ...any) -> (T)): (player: Player, ...any) -> (T)
1 Like

Ah, I see. Thank you!

function debugWrap<T, K>(name: string, func: (player: Player, ...T) -> (K)): (player: Player, ...T) -> (K)