Script Editor: Luau-Powered Autocomplete & Language Features Beta

Update: we have enabled table key auto-completion.

It’s based either on the required table type:
image

Or the first element of the array if type annotations are not used:
image

As always, we have other fixes coming including a fix for double ‘Enter’ key press when the word is typed completely, but sadly, not this week.

11 Likes

I don’t think this is expected nor ideal behavior for autocompleting long comments, please fix it

3 Likes

oh! Thanks for the heads up. This should be fixed when you restart Studio.

2 Likes

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
3 Likes

Awsome to see new things it will help out Luau Devs

2 Likes

When using the script formatter, it doesn’t take into account statements that span multiple lines and will cause an error to appear.
XfNMOThNg9

2 Likes

TweenService:Create seems to say that it returns an instance and not an Tween in specific, making the Tween type unusable.


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.

It works properly by not checking if it’s ~= nil and only checking if ClassType then.
This should be unfriendly to loleris’ coding style;

5 Likes

image

image

where’s my intellisense?


yes the beta feature is on

6 Likes

Could I get some feedback if this will be changed in the future or if there are other ways of fixing it?

3 Likes

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()
3 Likes

Using your code, this is what I get:

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.

Screenshot 2021-09-23 133028 (2)

1 Like

One thing to note is that when you’re indexing with : properties don’t show up at all!

2 Likes

I notice there hasn’t been any autocomplete for self, is there going to be an update to this?

2 Likes

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;

2 Likes

I mean, technically, a tween is an instance. (No, i’m not kidding. Try to parent a tween.)
Still weird however.

1 Like

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! :partying_face:

2 Likes

It seems as if the editor gets mad when I try to index something with [index] that isn’t a table, but that is indexable.

Adding [string]: any to the type doesn’t help.

image

8 Likes

We are working on a fix for this intersection type indexing error issue, but I’m not sure when it will be ready.

5 Likes

image

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.

image

Apparently it is not possible to make fast connections.

image

7 Likes

Would you mind sending screenshots of the types these should be?

Getting the code from the github I have no issues.
image

This should be an issue on your side.

5 Likes