← Luau typing quick reference

Read analyzer errors

Luau 0.731 · --!strict
path:line:column · message · first cause

Treat analyzer output as a source location plus a mismatch to repair, not as a verdict on the whole application.

When to use it

Use this exercise when luastra check reports a type error and you are unsure which part of the diagnostic should guide the fix.

  • Start with the first diagnostic that names one of your source files; later messages may be consequences of that mismatch.
  • Open the reported line and inspect the complete expression, function call, or table literal—not only the highlighted token.
  • Compare the required type with the value actually supplied. Here count is declared number, while the uncommented value would be string.
  • Fix the source contract or value instead of adding :: or any merely to silence the analyzer.
  • Run luastra check again. A real fix removes the diagnostic without creating a wider, less precise type.

Focused example

--!strict

type CounterState = {
    count: number,
}

local state: CounterState = { count = 0 }
state.count += 1

-- Uncomment this line, run luastra check, and inspect its location:
-- state.count = "one"

assert(state.count == 1)

Complete inventory

View all pages in Luau typing quick reference
← Previous: Runtime immutability with table.freezeNext: How to read table types →