Of course, lua can only typecheck at runtime. But here's an example:
local function f(x)
--assert(type(x) == "function")
return {dothing=x}
end
local v = f(nil)
v:dothing()
One problem with this code is that 'x' does not necessarily have to be a function to be callable. It could be a table that has a metatable with a __call field, or a user value with the same. The question "can this value be called?" is not that simple to answer.
local callable_types = { function = true, table = true } -- etc