The type checking warnings are not displayed
tracked
SuzannaLinn Resident
Using strict type checking doesn't display warnings in the Script Warning/Error window
--!strict
local function add(a: number, b: number): number
return a + b
end
local result1: number = add(3, 4) -- Should work fine
local result2: number = add("3", 4) -- Should trigger a type error in strict mode
This code in Luau/Roblox displays this warning:
Type Error: (8,29) Type 'string' could not be converted into 'number'
Log In
SuzannaLinn Resident
If you are not familiar with this, a brief explanation:
Luau (Roblox) helps write better and safer code by offering two powerful tools: type-checking and linting.
Type-checking means Luau can check your code to make sure variables and functions are used with the right kinds of values. For example, if you say a variable should be a number, Luau will warn you if you try to use a string instead. This helps catch bugs early, before you run the script.
Linting gives you helpful suggestions and warnings about your codeās style and structure. It can point out things like unused variables, typos, or confusing code. This makes your scripts cleaner and easier to debug.
Hopefully it will be added to SLua soon! :)
Signal Linden
tracked
Signal Linden
This one's a little tricky. The type checker is actually part of
luau-analyze
and not part of the script compiler. We'd have to bundle luau-analyze
into the viewer and get all that plumbed through, and that may take a while.Additionally, we haven't created type packs for any of our functions yet as the user-facing signatures are still kind of in flux. This is particularly true for functions that currently take flat lists with inline "parameter tags" like SetPrimitiveParams and friends. It's not clear that they can be type-checked well in their flat list form. They will probably get a nicer Lua-specific form using key/value pairs that can be correctly type-checked, but we're focusing on getting the fundamentals right first.
For the moment, if you want type checking you can use an external editor that supports Luau. The in-viewer editor is admittedly pretty bare-bones compared to what people'd expect from a modern editor.
WolfGang Senizen
It would be great to have a version of luau-analyze ship with the viewer.