The Luau type solver does not correctly register literal types when used as table keys.
Specifically, when defining a table with {[Literals]: someType}
, where Literals
is a union of string literals, the type inference does not properly recognise Literals
as valid keys.
This leads to an inability to assign a type to dictionary values without overwriting any existing dictionary keys.
This issue also occurs in --!strict
, --!nonstrict
and persist even with the new beta luau type solver
Reproduction
type Literals = 'exampleKey' | 'someOtherKey'
local Dictionary: {[Literals]: someRandomType}
Additionally, this bug prevents defining a generic dictionary type with literal string keys, making the following type impossible
type someDict<UnionOfLiteralStrings> = {[UnionOfLiteralStrings]: someRandomType}
Expected behavior
I expected Literals
to be properly recognised as Literals and not as a string