Is it possible to make recursive optional type in a table properties in luau new type solver?
Maybe something like this?
type function TableOptional(tbl: type)
if not tbl:is("table") then error("The first given type isn't a table!") end
for property in tbl:properties() do
local value = tbl:readproperty(property)
if value:is("table") then
TableOptional(value)
else
tbl:setproperty(property, types.optional(value))
end
end
return tbl
end
Edit: Can I maybe do it like this?
type function TableOptional(tbl: type)
if not tbl:is("table") then error("The first given type isn't a table!") end
for property in tbl:properties() do
local value = tbl:readproperty(property)
if value:is("table") then
tbl:setproperty(property, types.optional(TableOptional(value)))
else
tbl:setproperty(property, types.optional(value))
end
end
return tbl
end