#Does a plugin that auto annotate data types for module scripts that use OOP exist?

1 messages · Page 1 of 1 (latest)

quasi flax
vocal plover
#

golly imagine that, what a miracle that would be if such a thing existed. it doesn't and never will

quasi flax
#

I think its definitely doable might not be able to cover all edge cases until more grease is put into it tho

vocal plover
#

nope lol

quasi flax
vocal plover
quasi flax
#

dawg did you even read my question 🫩

vocal plover
#

yeah you want something that automatically adds types to everything and it's just never going to exist

quasi flax
vocal plover
#

luau already tries to infer types bruh

#

it can't even infer when you do local t={} t.__index=t t.func=function(self) end it cannot infer what self is

quasi flax
#

Did you see the link at the top of my post

vocal plover
#

do you really think i'm just saying stuff for the sake of saying stuff here? do you really, really think that I completely ignored your question and just making shit up?

quasi flax
vocal plover
#

i gave you a direct answer already bruh, that answer is no. i'm not sure why you're trying to appeal to me, that's not going to change the fact it's impossible...

#

at best you'd need an llm to do it for you, and we all know how reliable those can be

#

i mean, you don't have to believe me if you don't want to, but you have your answer 👍

#

just to press the point further; i have been coding in strict for the past several weeks and i can tell you things like, TextLabel, TextBox, and TextButton do not inherit from a related text class, so even though they share 99% of the same properties, you cannot do function setText(t:TextLabel|TextBox|TextButton,txt:string) t.Text=txt end it will complain the types are unrelated

#

another example of something that i'm fairly certain you cannot do; if you have a function that takes in a table of optional parameters, and returns a table that guarantees any parameter passed in will exist in the table, you almost cannot do that practically as far as i am aware

quasi flax
#

Im aware luau is limited here, and thank you for your time

vocal plover
#
function f(data:{a:string?; b:string?; c:string?}):{a:boolean; b:boolean; c:boolean} -- but only if they were in the input table
local r={}
if data.a then r.a=true end
if data.b then r.b=true end
if data.c then r.c=true end
return r
end

local out=f({a="a",b=nil,c="c"})```
and if you change the signature to optional like the input `{a:boolean?; b:boolean?; c:boolean?}` you have to refine the types after you call it even though you can guarantee it exists in the output. so how do you do it? well, functions can have union types, and you have to make every permutation of the inputs and outputs: ```lua
export type Permutation9x9<Ai,Ao,Bi,Bo,Ci,Co,Di,Do,Ei,Eo,Fi,Fo,Gi,Go,Hi,Ho,Ii,Io> = 
io<Ai&Bi&Ci&Di&Ei&Fi&Gi&Hi&Ii,Ao&Bo&Co&Do&Eo&Fo&Go&Ho&Io> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Gi&Hi,Ao&Bo&Co&Do&Eo&Fo&Go&Ho> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Gi&Ii,Ao&Bo&Co&Do&Eo&Fo&Go&Io> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Hi&Ii,Ao&Bo&Co&Do&Eo&Fo&Ho&Io> & 
io<Ai&Bi&Ci&Di&Ei&Gi&Hi&Ii,Ao&Bo&Co&Do&Eo&Go&Ho&Io> & 
io<Ai&Bi&Ci&Di&Fi&Gi&Hi&Ii,Ao&Bo&Co&Do&Fo&Go&Ho&Io> & 
io<Ai&Bi&Ci&Ei&Fi&Gi&Hi&Ii,Ao&Bo&Co&Eo&Fo&Go&Ho&Io> & 
io<Ai&Bi&Di&Ei&Fi&Gi&Hi&Ii,Ao&Bo&Do&Eo&Fo&Go&Ho&Io> & 
io<Ai&Ci&Di&Ei&Fi&Gi&Hi&Ii,Ao&Co&Do&Eo&Fo&Go&Ho&Io> & 
io<Bi&Ci&Di&Ei&Fi&Gi&Hi&Ii,Bo&Co&Do&Eo&Fo&Go&Ho&Io> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Gi,Ao&Bo&Co&Do&Eo&Fo&Go> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Hi,Ao&Bo&Co&Do&Eo&Fo&Ho> & 
io<Ai&Bi&Ci&Di&Ei&Fi&Ii,Ao&Bo&Co&Do&Eo&Fo&Io> & 
io<Ai&Bi&Ci&Di&Ei&Gi&Hi,Ao&Bo&Co&Do&Eo&Go&Ho> & --... continues for another 500 lines``` this works, but it has a problem; you cannot attach the optional inputs in there as far as i can tell so you lose autocomplete after typing the first input, but the output is correct! ... in this situation, assuming your magic auto-typing plugin existed, what kind of output would you expect from it?
quasi flax
#

unknown

#

Lmao

#

not that deep

vocal plover
#

so when i say such a plugin is impossible, it may not be obvious but i am speaking from experience. nothing can automatically type your code only you can do that because of the negative space

quasi flax
#

for simple types and even a little more complex ones its doable

vocal plover
#

if you're going over and manually checking the output is correct why not just do the types manually since you're already there?

#

i can agree type strictness is a bit annoying to work with, but it's not that bad when you get used to it

#

and in fact i'm fairly certain there are occasions where you are forced to use nonstrict for dynamic types as some things simply cannot be done at compile time

#

i haven't come across any concrete examples but i'm pretty sure there are issues with trying to type define entity classes

quasi flax
vocal plover
#

not bools

quasi flax
vocal plover
#

the problem is i have to refine the type of the return value if i just simply make them optional when i can guarantee it exists based on the input table

quasi flax
vocal plover
#

i decided to just accept this fact as part of its design, would be nice if there was a better way but i can't think of it. i'm also using the old typesolver maybe the new one has some tools that can do it

#

but both solvers can never fully infer everything automatically

quasi flax
#

And I don’t see how this relates to what I was originally asking anyway Im not asking for a magic typing tool just one that adds oop annotations

vocal plover
#

metatable types are even more involved

quasi flax
#

Id argue there will always be things heuristic type solvers cant solve as well and I think we are arguing about completely different things

vocal plover
#

e.g if you have type m=typeof(setmetatable({}::clsProperties,{}::clsMetatable)) and then have local x:m? if you try to do if x then x:someClassMethod() you seem to actually lose the metatable

#

on top of this, you cannot use unions in the metatable apparently

#

type m=typeof(setmetatable({}::clsProperties,{}::clsMetatable & clsExtension)) does not work, you lose the metatable entirely

quasi flax
#

But also I believe theres a new metatable function in the new type solver

#

havent tried it tho

vocal plover
#

so the output of any automatic type solver that you want to use is just going to complain it doesn't know how to solve your types, which is what i'm telling you rn

quasi flax
#

my type is lets say

local points = 1

vocal plover
vocal plover
#

that is type m = typeof(setmetatable({}::clsData, {__index:typeof(setmetatable({}::clsFunctors, {__index:clsParentIndex}))}))

quasi flax
#

lets go back here

#

wrong reply my bad

tired garnet
#

Hello

quasi flax
#

Hi duexo

tired garnet
#

Ok

vocal plover
#

so since that isn't in question, what remains is all the "edge cases"

quasi flax
#

Im not asking about "oh is there a plugin that can infer things luau cant"

vocal plover
#

the only point to a plugin, beyond what luau already does naturally, would be to solve things that luau doesn't already solve. there's a reason it doesn't infer those things as it is

#

coz it doesn't know how to

#

lol

quasi flax
#

dude

vocal plover
quasi flax
#

😭

vocal plover
#

if not that, what are you asking for exactly?

quasi flax
#

MAYBE you shouldve asked about this before being an ass and arguing with me about how luau works

#

You see how luau explicity makes you define the OOP types? even simple ones like name and balance so you can get self autocomplete since they are not restricted to self types

primal cargoBOT
#

studio** You are now Level 6! **studio

vocal plover
#

yeah it cannot infer the type of self, plugins cannot do it either

quasi flax
#

A plugin likely could simple types can be inferred quite easily

#

it would just have to infer the OOP data types and annotate automatically thats literally it

vocal plover
#

...it cannot infer the type

quasi flax
#

please dont start Im not talking about your complex edge cases a simple plugin/script could easily infer things like strings or numbers

#

Im aware luau already does basic typing for you but you have to do some additional annotation to get the type of self

#

This is honestly frustrating first time asking for help on this server and I have some ass that argues with me about something completely different than what Im asking for even tho I repeatedly tell the said ass that what he's arguing about isn't even what Im asking for

quasi flax
vocal plover
#

i honestly don't know why i even bother trying to help people yall just rude and disrespectful half the time

vocal plover
#

exactly - even though i gave you direct answer, you didn't like it and now saying its not help - so why am i wasting my time here

quasi flax
vocal plover
#

i suppose i should look at the bright side; i'm an ass because i didn't say what you wanted to hear. taking that home with me haha

quasi flax
#

Are we in an alternate universe where I asked “Hi can a plugin magically solve every luau type perfectly??”

frank fern
#

But in my experience it's still not perfect

quasi flax
#

Im gonna make one myself I couldn’t find one for my use case

quasi flax