luau
luau copied to clipboard
Using keyof or index with a class type in a table only gets a single property of a class
-- props is inferred as { Shape: Enum.PartType } when it should be more akin to { ["Shape" | "CFrame"]: CFrame | Enum.PartType }
local function create_part(
props: { [keyof<Part>]: index<Part, keyof<Part>> }
): Part
local part = Instance.new("Part")
for key, value in props do
(part :: any)[key] = value
end
return part
end