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

Support type inference via IsA #214

Open shirovian opened 1 year ago

shirovian commented 1 year ago

foo:IsA("Part") proves that foo is a Part but this code produces this error instead:

local foo = workspace:FindFirstChild("Foo")

if foo and foo:IsA("Part") then
    print(foo.Position) -- Roblox LSP Type Checking: "Key `Position` not found in type `Instance`."
end

Here it could be inferred that foo IsA Part, this would be an amazing quality of life change, I constantly have to write boilerplate to convince the type checker it will be of the already IsA asserted class in these scenarios.

Stefanuk12 commented 1 year ago

Additionally, FindFirstChild should return an optional type, and checking that it's not nil should resolve the proper Instance type.

DazorPlasma commented 8 months ago

Would really like to see this fixed. Currently it's a dealbreaker.