refactor(class): change type returned by lib.class

Return a new type named after the class, rather than OxClass.
We still can't use class generics (i.e. OxClass<`T`>), so classes
still need to be declared (e.g. ---@class Person : OxClass).

Also removed the experimental warning.
This commit is contained in:
Linden
2024-07-26 15:23:43 +10:00
parent 026d3de4ef
commit e10e8af0de

View File

@@ -1,10 +1,6 @@
---@diagnostic disable: invisible ---@diagnostic disable: invisible
local getinfo = debug.getinfo local getinfo = debug.getinfo
if not getinfo(1, 'S').source:match('^@@ox_lib') then
lib.print.warn('ox_lib\'s class module is experimental and may break without warning.')
end
---Ensure the given argument or property has a valid type, otherwise throwing an error. ---Ensure the given argument or property has a valid type, otherwise throwing an error.
---@param id number | string ---@param id number | string
---@param var any ---@param var any
@@ -132,8 +128,10 @@ end
---Creates a new class. ---Creates a new class.
---@generic S : OxClass ---@generic S : OxClass
---@param name string ---@generic T : string
---@param name `T`
---@param super? S ---@param super? S
---@return `T`
function lib.class(name, super) function lib.class(name, super)
assertType(1, name, 'string') assertType(1, name, 'string')