Skip to content

Checked

For types that are especially hard to describe, you could use checked. Checked is generally an any Datatype which allows you to pass a "sanity check" callback. This makes sure that even though Roblox's default networking is used, you still get proper type validation & annotation.

function light.datatypes.checked

Shared Synchronous
1
2
3
function checked<Input, Checked>(
    sanity_check: (Input) -> (Checked)
): (Datatype<Checked>)

Example

Let's say you want to send a SkateboardPlatform across the network. (Blasphemy)

blasphemy.luau
1
2
3
4
5
6
local ty = light.datatypes

local skateboard_platform = ty.checked(function(input: Instance)
    assert(input:IsA("SkateboardPlatform"))
    return input :: SkateboardPlatform
end)