mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
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:
@@ -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')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user