I want to create a type that is essentially what a function returns. ex.
function Ibuf()
return {
alt = "ernative"
}
end
type Ib = Ibuf
function Eru(Var : Ib)
-- then as I type "Var", intellisense would give me something relevant
-- showing me an option called "alt" that's supposed to be a string
end
What’s the most convenient way of doing something like this?
That works for this case, but with a more complicated return:
function Ibuf()
local object = {
goddamn = "thisnoise",
insidemy = "head",
bot = true,
skipper = math.random(1, 3)
}
function object:noway(victim : BasePart)
victim.Parent = nil
end
function object:print(a : number, b : number, c : number)
print(a)
print("----- . -----")
print(b + c)
print(b .. "eheheh" .. c)
end
return object
end
Manually writing down types for all of it just to get intellisense after saying “this function should use what Ibuf returns” gets ridiculous.
Small price to pay for intellisense to be honest.
I’ve literally had to deal with no IntelliSense for my class objects for 1.5years because I use a class module called MiddleClass.
The way that works is via metamethods and causes basic intellisense to get lost.
I just recently discovered that this type stuff can bring back intellisense and managed to use it properly with it.
It may seem like alot but if you’re doing one and done things, some extra time with types isn’t so bad if you don’t have to review the code every 5 minutes for args.
Types only exist at compile time, and do not effect the code at runtime what-so-ever, they are effectively stripped out of your code when it runs, so you don’t have to worry about it existing or running when you put them in.