I use middleclass for OOP, and was wondering is there a way you can type methods with luau?
Lets say I have a class such as the following
local class = require(game.ReplicatedStorage.Middleclass)
local Unit_S = class("Unit_S")
function Unit_S:initialize(guid, template)
self.GUID = guid
self.Name = template.Name or "Unknown"
self.Position = template.SpawnPosition or ZERO_VECTOR3
self.Immune = 0
-- etc.
end
function Unit_S:IsImmune(): boolean
return self.Immune > 0
end
return Unit_S
And I want to type it like this:
export type CombatUnit = {
IsImmune: () -> boolean,
}
It results in the following:
I also tried
IsImmune: (CombatUnit) -> boolean,
to no avail.
Is it possible to type class methods at all?


