RobloxLsp
RobloxLsp copied to clipboard
Support type inference via IsA
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.
Additionally, FindFirstChild
should return an optional type, and checking that it's not nil should resolve the proper Instance
type.
Would really like to see this fixed. Currently it's a dealbreaker.