Hello! so i’ve been experimenting with generic typing, but i’ve hit an obstacle that i genuinely don’t know what is happening
so my goal was to make it so that if i give a function a table as an argument, the typecheck is the type of the .controls value of the table, which ended up looking like this
function load<V>(handler): V
local data: V = handler.controls
end
the weird part is that it sometimes does work, and sometimes doesn’t, and i genuinely dont know why, is there any way i can make it more reliable???
oh, i asked the AI assistant for help, it gave me this function
function load<V>(handler: { controls: V }): V
local data: V = handler.controls
return data
end
it somehow worked, i have no idea what the hell in there caused it to work, but if it works, it works,… i guess
oh wait i finally understood, so to anyone who comes later here and wants the answer:
the controls: V inside the parameters is giving the generic type V the type of handler.controls, i didnt know it was possible, but now that i know, it’s gonna be a blast to use it!