Just wanted to give you a notice. Not sure if this is a bug or just unaccounted for. Currently this code:
if object:FindFirstAncestor("Ancestor") then
if object.Parent.Name == "ParentName" then -- the type engine will report: Type 'Instance?' does not have key 'Name'
-- unrelated code
end
end
should not be causing this suggestion. If the object is known to have an ancestor than it is guaranteed to have a parent because without a parent it cannot have an ancestor. Or are logical arguments like this not yet implemented in the type checking engine?
Edit:
Another thing I noticed, iterating through children in a for loop using (i)pairs and Instance | Roblox Creator Documentation leaves the second argument in the for loop as a general instance object. What I mean is this:
for _, child in pairs(instanceObject:GetChildren()) do
if child.Parent then -- have to do this check because child.Parent type is Instance? instead of Instance even though we already know it has a parent
-- other code
end
end
This might’ve been already reported, not sure.
Script Editor doesn’t handle == nil, ~= nil, and similar ones comparasions properly, when handling a var with is set to a type | nil as seen below, this leads it to highlight lines with a warning.
You don’t need to do this for classes (in specific), if you’re using the Luau standard for classes, which is this:
local Class = {}
Class.__index = Class
function Class.new()
return setmetatable({
-- ...
}, Class)
end
function Class:method()
-- ...
end
return Class
What you can do, is get the type from that class automatically.
export type Class = typeof(
Class.new()
)
This gives you a type with all the methods and etc from that table, taking metatables into account, so you can see methods etc, so it’s fine.
Also know that I’m pretty sure you need to do this only once all methods are defined, because otherwise those won’t show up, afaik. But also don’t worry about that too much because you wouldn’t need to define a function to say that it returns that class most of the time anyway, as that should be automatically handled by Luau.
cant confirm right now but chaining may not work
classes that work with chaining might not work…
function Class:method1()
-- Do something...
return self
end
function Class:method2()
-- Do something...
return self
end
-- On Script:
Class
:method1()
:method2()
Actually I don’t want to see the __index, but I guess I have to live with that.
Furthermore I have a problem where parameters of functions are not shown. I can see at the autocomplete suggestions that it knows all the parameters/return types and hovering over it shows that it recognizes the metatable where the functions are in. However when I’m between the two brackets, it doesn’t display anything unlike it normally would at functions.
Some time ago, my Signal implementation changed the way connections/linked list nodes work, not being the same thing anymore, and basically they just point to each other. Anyway, in some way or another it at least seems like this was what broke auto-completion for me.
I can’t see why this is happening at all, I would appreciate you guys could investigate this because it’s bound to affect other people, if anything it would be nice to know what’s wrong here;
Yeah I’ve known this for a while, Tween is a specific type though, like each pretty much every instance has a specific type to it, for example the Tween type has Tween specific members, like :Play, :Stop, .Completed on it.
Anyway this was fixed like one week after I mentioned it so!
There’s a small problem that occurs in my Signals Service, when I try to make a direct call of the service’s functions it generates an error saying that the argument of the function is incorrect and that ‘self’ is missing.
Apparently it is not possible to make fast connections.