When using a function that implements the keyof type function, any proper use of singletons calling the function is incorrectly marked as wrong in --!strict mode.
The editor marks this as Type 'string' cannot be converted into "foo" Expected behavior
If everything worked correctly, foo is a valid key of type Hello, so use of hi("foo") meets keyof<Hello>.
I still don’t think that this is intended because I don’t think Luau devs intended for everyone to have to spam "foo"::"foo" everywhere in their code.
Continuing,
the keyof example would fail if for that to be true.
Oh, and also, if I replaced my example with a regular union, the editor doesn’t complain. This isn’t intended.
Thank you for the report! This looks like a regression in how we handle inference for primitive vs singleton types. When keyof was originally introduced, I added specific logic to influence singleton type inference when the expected type has keyof in it. If this just started happening recently, it might be related to some of the generalization changes we’re making, but most likely, the regression is somewhere in the handling of expected types. We’ll take a look as soon as possible, cheers!