I found an amazing resource that explained typechecking simply earlier and have been playing around with it. It seems I’ve run into a case where what should be invalid and flagged by the checker is being registered as ok. Not sure if I’m misunderstanding typechecking or if I should file a bug report.
--!strict
-- Expect number key or nil and any value or nil
type Array = {[number?]: any?}
local foobar: Array = {
"foo", "bar", "garply",
["foo"] = "bar", -- One non-numerical key, does not get flagged
}
local barfoo: Array = {
["foo"] = "bar",
["gar"] = "ply",
} -- All non-numerical keys, gets flagged
Does this also when I use the array-like table special syntax.