Skip to content

Commit

Permalink
refactor(class): change type returned by lib.class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thelindat committed Jul 26, 2024
1 parent 026d3de commit e10e8af
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions imports/class/shared.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit e10e8af

Please sign in to comment.