Luau TypeChecking help

So it’s been a couple years of me being away from Roblox, and I’d like to see what’s changed with the TypeChecking

Have they added descriptions to it yet?
image
such as this?

and if there’s been any huge changes to it, can you note that aswell thanks!

1 Like

I’m not sure if there’s anything “new” per se specific to type checking (since a “few years” is a pretty broad term), it’s mostly refinements to existing systems (especially the linter). Basically everything is documented here though, but if there’s anything you need clarification or any further examples feel free to ask:

This is actually implemented but it isn’t actually a typechecking thing. It’s done with the script editor API:


On a side note there have been a few large additions to the language in the recent years that aren't specific to type checking which are frankly pretty impressive to see.

Some are features implemented in newer versions of Lua, which are documented here:
Compatibility - Luau

One of if not the biggest new implementation exclusive to Luau since a few years ago is string interpolation. It’s also the newest big addition so if you’re familiar with that from other languages like JS, it was added to Luau. It acts as a safe and faster method to formatting/concatenating strings.

local var = 'example of an'
local a = `hello this is an {var} interpolated string` --> hello this is an example of an interpolated string

It works with the __tostring metamethod and stuff as well. But I’m not gonna dwell on that for too long.

Another feature is generalized iteration which acts as a cover-all generic “iterator” that basically is a combination of pairs and ipairs. It’ll iterate over a typical array or a typical dictionary in a specific manner depending on the table’s contents but it’s very reliable and is about the same speed as pairs and ipairs. To use this iterator you’d just do for key, value in t do, where t is a table or dictionary.

With generalized iteration there’s also the added __iter metamethod which allows you make your own iterator function that can be called when a table is iterated over using the aforementioned for loop syntax

I’m not sure if you were here or not when it was added but there’s also the added functionality of ‘if-then-else’ expressions which act as in essence a proper ternary operator, so local a = if a then b else c, and local a = if a then b elseif c then d else e are both valid syntaxes.

There’s also compound assignments but that’s going back quite a bit. Basically a += n is equal to a = a + n. There are a couple scenarios where they aren’t exactly equivalent but those are very niche and won’t happen to most people (they’re also documented on luau-lang.org). The following compound assignments are valid: %= -= += *= /= ..- ^=

Continue statements also exist but again that’s going back quite awhile

2 Likes