How would I type define metatables?

Hello, I would like to know how I would type def metatables. I looked through a lot of devforum posts all saying how you set a metatable but no solution.

lets say I would make a metatable that looks like this
image

now roblox type definition can tell that E is a valid key and give autocorrect suggestions
image

roblox even recognizes it when we use typeof in another type!
image

and roblox seems to have type support for metatables
image

but I wanna know, is there a way to define it plainly?
image
maybe something like this?

edit: I know about type merging but I just wanna know if there’s a way to define a metatable in the type

No, typeof(setmetatable({ key = value }, { metaKey = metaValue })) is the only way.

It appears that roblox is considering alternatives but it’s not looking like there’s much hope for syntax updates soon.

1 Like