NightrainsRbx / RobloxLsp

Roblox Luau Language Server based on Lua by sumneko.
https://devforum.roblox.com/t/roblox-lsp-full-intellisense-for-roblox-and-luau/717745
MIT License
218 stars 53 forks source link

Extended class functionality #216

Open Stefanuk12 opened 1 year ago

Stefanuk12 commented 1 year ago

Reference code

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: