Hey! Suddenly, I’m not receiving LuaU type errors, for example, you can see that in the ModuleTypedef type, the index should be a number, but I put a string, and it’s not giving me an error in the script editor…
How can I fix this?
The autocomplete menu also doesn’t shows:
This bug/problem happens when I use table indexers, example without the table indexer:
I’m still having this error… I’m thinking this is a bug, and I would like to gather attention to Roblox bug staff, so they can do something about this… If there’s any thread posted in the forum talking about how to post a #bug-reports without being a Regular member, please send me it on private messages.
But now, the problem should be that the editor should have underlined it with an error that it should be a number and not a string (before this happened it used to be like that).
--!strict
type MyType = { a: number }
-- this is fine, we can use a wider type in assignment
local x: MyType = { a = 1, b = 2 }
-- ... but we can't actually access that additional property
print(x.b) -- error!
x.b = 3 -- error!
This is an intended feature.
If you really wanted you could explicitly say “all other keys should be nil”, but then you wouldn’t get errors when accessing non-explicitly-defined properties:
--!strict
type MyType = { a: number, [any]: nil }
local x: MyType = { a = 1, b = 2 } -- error! 2 is not nil
print(x.b) -- NOT an error anymore, just always nil
print(x.asdf) -- also NOT an error
x.b = 3 -- error! 3 is not nil