← Luau typing quick reference

Function types

Luau 0.731 · --!strict
(Parameters) -> Returns

Callbacks and ordinary functions can be typed. () after the arrow means the function returns no values.

When to use it

Read this page when you need to apply Function types, verify its exact contract, and adapt the example without bypassing validation or host boundaries.

Focused example

--!strict

type TapHandler = (action: string, target: string) -> ()
type Validator = (value: string) -> (boolean, string?)

local validateEmail: Validator = function(value)
    if string.find(value, "@", 1, true) == nil then
        return false, "Email must contain @"
    end
    return true, nil
end

local accepted, message = validateEmail("reader@example.com")
assert(accepted and message == nil)

Complete inventory

View all pages in Luau typing quick reference
← Previous: GenericsNext: Exported module types →