Latest Update
What is Classe?
Classe is a highly typed module designed to solve issues related to class organization, typing, and performance in Luau.
It automatically infers object types, including inheritance cases, eliminating the need to manually define types or reuse metatable class templates.
Classe also applies performance-oriented approaches by avoiding __index chains.
Requirements
To work correctly, you must enable the Beta Luau Type Solver in Roblox Studio settings
Autocomplete demonstration
Basic Class
local Classe = require(script.Parent.Classe)
local Weapon = Classe.meta({} :: {
bullets: number
}, {})
type Self = Classe.Self<typeof(Weapon)>
type ISelf = Classe.ISelf<typeof(Weapon)>
function Weapon.shot(self: Self)
self.bullets -= 1
print("Boom!")
end
function Weapon.construct(self: ISelf)
self.bullets = 10
end
return Classe.build(Weapon)
Inheritance
local Classe = require(script.Parent.Classe)
local Weapon = require(script.Parent.Weapon)
local Rifle, super = Classe.meta({} :: {
isAiming: boolean
}, {}, Weapon)
type Self = Classe.Self<typeof(Rifle)>
type ISelf = Classe.ISelf<typeof(Rifle)>
function Rifle.aim(self: Self)
self.isAiming = true
print("aiming...")
end
--[[
also use the init key function,
which will be called after construct
]]
function Rifle.init(self: Self)
print("bullets:", self.bullets)
end
function Rifle.construct(self: ISelf)
super(self)
self.isAiming = false
end
return Classe.build(Rifle)
Speed and memory
Classe is primarily focused on performance rather than memory efficiency.
During inheritance, the parent’s metadata is copied into the child. This should not significantly impact memory usage, since mostly function references and primitive values are copied, which are inexpensive on their own.
This approach improves method call performance because it avoids __index chains and additional lookups across the inheritance hierarchy.
If a class has subclasses and its metadata needs to be modified, __newindex is triggered. It iterates through all child classes and updates the corresponding data, while checking whether the metadata has been overridden in the subclass.
Here is a method call at the 99th level of inheritance (500k tests)






