You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript has types/aliases like Parameters<...> which accept a function and resolve to their arguments, or ReturnValue<...> which does the same for return value, etc. as well as other cool things like Exclude and so on. I don't think this plugin will ever quite reach TypeScript's power, but I recently came across a situation where I was typing a pcall-like function, and would've liked to express that it takes the same extra arguments that the function itself takes.
Would also probably require a new annotation for declaring the entirety of a vararg (as a TyMultipleResults ) rather than the type of each element of the vararg.
Quick demonstration:
-- `varargs` annotation below. as opposed to `vararg` which specifies the type of each vararg,-- `varargs` specifies the type of all of the entire varargs--- @genericF:function--- @paramfuncF @function to spawn in a new thread--- @varargs Parameters<F> @parameters to call the function with--- @returnReturnValues<F>functionthread.spawn(func, ...) end
thread.spawn(function(a, b, c)
-- a, b, c are all inferred as number due to the below parametersend, 1, 2, 3)
thread.spawn(some_func, 1, 2,3) -- either some_func is required to take (number, number, number), or the arguments after some_func
Would also make pcall more accurate
The text was updated successfully, but these errors were encountered:
TypeScript has types/aliases like
Parameters<...>
which accept a function and resolve to their arguments, orReturnValue<...>
which does the same for return value, etc. as well as other cool things like Exclude and so on. I don't think this plugin will ever quite reach TypeScript's power, but I recently came across a situation where I was typing apcall
-like function, and would've liked to express that it takes the same extra arguments that the function itself takes.Would also probably require a new annotation for declaring the entirety of a vararg (as a TyMultipleResults ) rather than the type of each element of the vararg.
Quick demonstration:
Would also make pcall more accurate
The text was updated successfully, but these errors were encountered: