Strict mode

The Luau type-checking mode that infers a type for everything and reports anything that does not fit.

Think of it as An inspector who reads every jar label before the kitchen opens.

A --!strict comment on the first line, or languageMode strict in .luaurc, turns it on. The other modes are nonstrict (the default, which reports only definite errors) and nocheck. Strict mode runs in the editor and in tools such as luau-lsp analyze, never while the game runs.

Where the picture breaks

Labels are checked before the game runs, and only then. While it runs, nothing reads them, so a value that arrives from a client or a DataStore can be anything whatever its label says.

Annotations feed a static checker that runs on the source code. At run time Luau ignores them. Code that receives outside data marks it unknown and narrows it with typeof, comparisons or type guards before treating it as a specific type.

See it with the rest of the analogy cast

Official reference: create.roblox.com

Related terms