As a Roblox developer, it is currently too hard to
convert table/type keys to a type. My idea is to add a keyof operator that would turn the keys into type.
Example:
--!strict
local a = {
a = 1
b = 2
}
function GetValue(Key: keyof(typeof(a)) -- a | b)
return a[Key]
end
If Roblox is able to address this issue, it would improve my development experience because at the moment I am writing my framework in the likeness of a knit, and in functions like GetService it would be good to use keyof
@bitsplicer It being merged into Luau does not mean it’ll appear in Roblox Studio immediately or even around that time.
As I said when I linked that RFC in the first place, we usually have to wait for Roblox to implement it into Studio, and evidently, this claim holds up because it’s been about 2 months since it was merged and is just now being introduced.
As a head’s up, even though the RFC has been merged and the feature has been implemented, it won’t be available within Studio for a while yet. The Luau team is working on a total rewrite of Luau’s type analyzer and keyof is only implemented in the new version.
I am told it will arrive “soon™” by team members on Discord, so make of that what you will.
Has a developer, I need this ! it’s been 4 months since we want it to be uploaded into Roblox Studio, what are you waiting for ! Strict developer will be happy
keyof is only available in the new type solver, which isn’t in a state that is ready for release. On Discord an engineer said that they hope to have the beta out soon (within a couple of weeks), but ultimately it will be ready when it is ready.
What is the suggested use for nodeof? There’s a variety of type functions like keyof in the new solver, but it’s not clear if what you want is already added.