Open RealEthanPlayzDev opened 1 year ago
This happens when error was generated at a point where type wasn't known to be ConnectionObject?
.
I would suggest adding a type annotation to avoid the error:
type Function = (...any) -> (...any)
type ConnectionObject = {
Disconnect: (self: ConnectionObject) -> ()
}
type SignalObject = {
Connect: (self: SignalObject, f: Function) -> (ConnectionObject?),
}
type SignalInterface = {
Signal: SignalObject
}
function Once(self: SignalInterface)
local Connection: ConnectionObject?; Connection = self.Signal:Connect(function(... : any)
if Connection and typeof(Connection["Disconnect"]) == "function" then
Connection:Disconnect()
end
end)
return
end
I would suggest adding a type annotation to avoid the error:
From my understanding, wouldn't the SignalObject
's Connect: (self: SignalObject, f: Function) -> (ConnectionObject?)
already handle this? (as in the return being a ConnectionObject?
)
Reproduction code
Can be reproduced on
luau-analyze
) (MSBuild VS2022)luau-analyze
) (MSBuild VS2022)