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
local hi = {}
function hi.new()
local b = {}
b.Sick = 1
b.run = "hi"
function b:Rap()
print("RAPPIN'")
end
function b.No()
print("uhh")
end
return b
end
export type raiter = typeof(hi.new(...))
return hi
local system = {}
function system.new()
local base = {}
local private = {}
function base.newEnumerator()
local h = {}
h.NNn = 1
return h
end
export type EnumerateCall = typeof(base.newEnumerator())
return base
end
export type SystemCall = typeof(system.new(...))
return system