Could I get some feedback if this will be changed in the future or if there are other ways of fixing it?
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()
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.
One thing to note is that when you’re indexing with :
properties don’t show up at all!
I notice there hasn’t been any autocomplete for self, is there going to be an update to this?
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;
I mean, technically, a tween is an instance. (No, i’m not kidding. Try to parent a tween.)
Still weird however.
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!
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.
We are working on a fix for this intersection type indexing error issue, but I’m not sure when it will be ready.
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.
Would you mind sending screenshots of the types these should be?
Getting the code from the github I have no issues.
This should be an issue on your side.
Because « **.Event ** » is a callback method and u try to make a function when the replicated storage is fired. Try to change the event name with a name
it’s back…
for me, I’m not sure, but was it removed?
update: nevermind, the feature was turned off for me somehow
Will we be seeing improvements to require()
when getting modules with this beta?
For example, with my experiences framework, I have variables saved in a dictionary with object references to the folders I keep my modules in. They support autocomplete for any property and other children, but when using require()
on it, said variable will not show any autocomplete.
Having this feature would be very useful as it can greatly help with experience organization.
On a similar topic, having support for requiring a modulescript returned by a function would be very handy. This would enable me to create a require-by-name, which helps with organization of large codebases.
One or both of these features would greatly increase my codebase organization and my speed of developing. I am currently working on a game with around 300 modules, and not having type checking with my system can really slow down development speed.
Improving require()
would be great, but sadly, current limitations that we have don’t allow us to support these use cases.
The main limit here is that we construct the graph of module dependencies before we start type-checking each one.
If we change the implementation to type-check each module at the require()
point, we should get the necessary type information and resolve the DataModel path.
We are aware of use cases where require()
is called through a wrapper, and this case is even more complex as it requires us to somehow ‘execute’ the function to figure out how the input string is transformed (if it is).
If we make such improvements in the future, they will be released outside Autocomplete Beta feature (script analysis error reporting can benefit from require()
tracing improvements as well).
Has this beta feature been turned on by default for all users? I noticed it disappeared from the Beta Features menu, and have been getting consistent crashes (100% of the time) in certain places that all use Luau types.
EDIT:
After spending most of the day flipping flags and trying to make studio work it seems that the flag “LSPAutocomplete_preAlpha” crashes our games in studio 100% of the time. Even when never using the built in script editor (or autocomplete) at all.
Sorry for the trouble.
We are rolling out this Beta feature to more developers and we did receive some new crash reports after a recent extension.
We are working to fix at least two main issues we’re seeing for the update next week.
Adding to the conversation about legibility and ease of use…
Are there any plans for visualizing script editor setting changes more easily?
Unless I’m missing something, I have to go back and forth between Studio Settings and my script editor to test changes. This means I have to close and reopen the settings menu a bunch of times for some very annoying trial and error.
In addition, is there a way (or will there be a way) to specifically set a font type/size for just the autocomplete / menu section? My script editor font isn’t a good match for autocomplete or the menu.
Lastly, are there any plans for different menu scalings or positions? Occasionally you get autocompletes that heavily block what you were just typing:
Still happening to me when using inline if-statements
local bar = (
if (foo) then
"foo"
els -- autocomplete says ElapsedTime
)