local EnumObject = {}
EnumObject.__index = EnumObject
function EnumObject.new(enumType: string, children: {string}): self
local self = setmetatable({}, EnumObject)
self.enumType = enumType
self.children = {}
self.enumItems = {}
for _, v: string in children do
local tableAdded = {
Name = v,
Value = (#self.enumItems + 1),
EnumType = self.enumType
}
table.insert(self.enumItems, tableAdded)
self.children[v] = tableAdded
end
return self
end
print(EnumObject.new("Main", {"time", "monparnasse"}).children)
export type self = typeof(EnumObject.new(...).children) --children work but children of children doesn't work help me please !
return EnumObject
2 Likes
Im not sure but what about:
type table: {Name: string, Value: number, EnumType: Enum}
?
edit: sorry you meant auto-typage:
type table: {Name: any, Value: any, EnumType: any}
if this is the type of “auto” typage you mean? like that it accepts anything?
1 Like