local Class = {}
Class.__index = Class
do
function Class.new()
local self = setmetatable({}, Class)
self.Variable = true
return self
end
function Class:Test()
print(self.Variable)
end
end
Request
Within the constructor, self.Variable is set. In Class:Test, self.Variable's type is any when it could be boolean?. If another method is added, which modifies self.Variable and therefore gives it a new type, should be picked up.
function Class:Modify()
self.Variable = "Modified"
end
Therefore, self.Variable's type should now be (string | boolean)?
Problems
There are a few problems with doing this though:
How do we know which method is the constructor, if it's something other than .new()?
Reference code
Request
Within the constructor,
self.Variable
is set. InClass:Test
,self.Variable
's type isany
when it could beboolean?
. If another method is added, which modifiesself.Variable
and therefore gives it a new type, should be picked up.Therefore,
self.Variable
's type should now be(string | boolean)?
Problems
There are a few problems with doing this though:
.new()
?