As discussed here: Need help doing type checking for all values in a dictionary
Here is my code:
--!strict
local dict: {[string]: boolean} = {
code1 = true,
code2 = false
}
When I change the value of key code1 from true to 123, Studio’s new Beta Luau typechecker warns me that this is invalid. So far so good, this is expected, since I explicitly said that dict has a type {[string]: boolean}, and putting a number there would be a silly mistake that it should catch.
Problem:
However, I don’t get a warning if I make this same mistake for the next line, and change code2’s value from false to 123. For some reason, the New Beta type checker is ok with this and does NOT put a warning, even though I do want it to tell me that I’m making a mistake.
It seems like it only validates the type for the first key value pair in the dictionary, but not for subsequent pairs.
Expected behavior
I expected to get a type solver warning if ANY of the values in the dict did not match the type I declared. Please let me know if this expectation is misinformed. In the meantime, to get this desired behavior, I switched back to normal studio settings and opted out of the beta.