Given;
type Token = { read Type: "Letter" } | { read Type: "Number" }
local correspond: { read [string]: index<Token, "Type">? } = {
A = "Letter",
["0"] = "Number",
}
, I would expect the code to typecheck without errors. However,
Type errors are reported on both of the values, the "Letter" and "Number" string literals were not inferred to be singletons. Autocomplete seems to work fine though:
Casting the literal to its singleton ("Letter" :: "Letter") mitigates the type error.
Playground
Given;
, I would expect the code to typecheck without errors. However,
Type errors are reported on both of the values, the
"Letter"and"Number"string literals were not inferred to be singletons. Autocomplete seems to work fine though:Casting the literal to its singleton (
"Letter" :: "Letter") mitigates the type error.Playground