Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support type inference via IsA #214

Open
shirovian opened this issue Mar 11, 2023 · 2 comments
Open

Support type inference via IsA #214

shirovian opened this issue Mar 11, 2023 · 2 comments

Comments

@shirovian
Copy link

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
Copy link

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

@DazorPlasma
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants