It’s not bad per se, but it can produce strange large types from inference that are hard to work with.
In your case, it’s unavoidable because typeof is the only way to get a table type with a metatable in the old solver. In the new solver, however, you might be able to use a type function like setmetatable<SignalInstance<T...>, {__index: SignalPrototype<T...>}>.
When you use typeof, you lose control over your data. It’s like a black box that makes everything work, but without being sure why.
Also, another big advantage of type systems is that they let you describe your code precisely. For example, in your case, you can know exactly what the shape of Signal and Connection is, and at the same time, the type checker can do its job. When using typeof, you lose that.
Of course, there are legitimate use cases for using typeof, like dealing with third-party libraries, legacy code, or when you just want things to work.
What are you talking about?
He uses it to grab metatable results.
You don’t have any of those properties; they are essentially stored under __index callback.
You don’t know what you are talking about.
@WaffIe_Cake keep doing what you were doing
Those suggestors don’t know what they are talking about.
That’s obvious. But you’re not saying why this way is better or why my suggestion is worse. I’m basing my reasoning on POLA (Principle of Least Astonishment), which expects a system’s behavior to be what a reasonable developer would anticipate. There shouldn’t be any “hidden magic.”
Again, why? These things don’t help anyone. Please explain yourself.
FWIW, using typeof with metatables is the standard way to type OOP currently. The new solver adds a setmetatable type function, which makes this a bit cleaner, but that’s still in beta:
export type Signal<T...> = setmetatable<SignalInstance<T...>, {__index = {} :: SignalPrototype<T...>}>
You still don’t know what you’re talking about.
And please stop tossing around buzzwords you clearly don’t understand - it doesn’t make you look smart, it just makes your argument weaker.
A table doesn’t have those values in the first place, so your point is just wrong.
Becouse i did already, and yet you keep throwing nonsense and deflecting.
Table does not contain methods dirrectly.
It will be a super devastating in the future once typecheck will affect bytecode.
You should use either type function setmetatable<> or typeof(setmetatable({},{})) shenanigan