luau icon indicating copy to clipboard operation
luau copied to clipboard

Using keyof or index with a class type in a table only gets a single property of a class

Open gaymeowing opened this issue 1 year ago • 0 comments

-- 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

gaymeowing avatar Aug 29 '24 00:08 gaymeowing