I omitted it for simplicity of the example but it’d look something like this if I wrote them:
type PrivateVariables = {
name: string -- yippee! type safety
}
loca privateVariables: { [Something]: PrivateVariables } = {}
local Something = {}
Something.__index = Something
function Something.new(): Something
local self = setmetatable({}, Something)
self.nothing = nil
privateVariables[self] = {
name = name,
} -- tadaaaa
return self
end
type Something = typeof(Something.new(…)) -- right under new, before methods
function Something.doSomething(self: Something): ()
privateVariables[self].name = 2 -- type warning! i think… i’m on mobile so i can’t test it
end
return Something