Get the type returned by a function

Hello, are there functions in Luau for typing related to:

  1. Getting the return type of a function

function foo(n: number): string
  return "hello"
end

local a: call<typeof(foo)>
  1. Getting the parameters of a function

function foo(n: number): string
  return "hello"
end

local a: params<typeof(foo)>
1 Like

Edit: code comment
Yep! Just use type and more characters: :upside_down_face:

function foo(n: number): string
	return "hello"
end

type ReturnType = typeof(foo)

local a: ReturnType

-- for parameters: manually
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.