From e10e8af0de655cbd8fa99c0d27840234c91828cb Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:23:43 +1000 Subject: [PATCH] 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. --- imports/class/shared.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/imports/class/shared.lua b/imports/class/shared.lua index 8781673..bf91125 100644 --- a/imports/class/shared.lua +++ b/imports/class/shared.lua @@ -1,10 +1,6 @@ ---@diagnostic disable: invisible 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. ---@param id number | string ---@param var any @@ -132,8 +128,10 @@ end ---Creates a new class. ---@generic S : OxClass ----@param name string +---@generic T : string +---@param name `T` ---@param super? S +---@return `T` function lib.class(name, super) assertType(1, name, 'string')