What's the point of type checking if it doesn't error if it's changed?

Sorry if I misunderstood something about this type-checking thing, but why doesn’t this error:


local ServerStorage : ServerStorage = game:GetService("ServerStorage")

ServerStorage = 1


It is supposed to error because the variable ServerStorage is already typed with the Class ServerStorage.

It instead prints out 1 rather than throwing an error.

Or am I wrong with something?

It’s not supposed to error more like a warning while you are still writing the script, more of an organizational tip to know what type a variable is supposed to be while scripting rather than after scripting during play testing/

it’s better to prevent errors rather than clicking that big play test button waiting for the game to load before getting with a big ERROR.


Also it helps with Luau autocomplete which is my main reason of doing it, example is looping through a table with a function, there is no autocomplete unless you manually initially add a instance in the table


auto complete does come up if you define it

for i, v : BasePart in pairs(t) do
1 Like