The return value of
:FindFirstChild() should be
Instance?, but typechecking is reporting that it is
--!strict is enabled. Correct me if I’m wrong here.
Edit: a nasty side effect of this is I cannot downcast to
Folder?. I have to first cast to
any which is pretty nasty
local leaderstats = (player:FindFirstChild("leaderstats")::any)::Folder?
For a workaround you can do this for now until it’s fixed:
local diamonds: IntValue? = <code> :: IntValue
Cheers fellow type checker.
Thanks for the report! We’ll follow up when we have an update for you.
This is a decision we made to balance false positive error reports in the current system we have set up.
We might change our decision when additional type inference improvements are completed, but for now we are not ready to switch T over to T? for FindFirstChild.
Maybe as a short-term solution, it will be better for us to make Base → Derived? cast work.
Base → Derived? would be a wonderful addition