Currently the method is typed as Instance:QueryDescendants(selectorGroup: string): {Instance} regardless of what selectorGroup is set to. For example:
game:QueryDescendants("LuaSourceContainer") --> {Instance}
I know that this will always return {LuaSourceContainer}, but type checker doesn’t know that. I am forced to either ignore this, or type cast :: in strict mode, both of these workarounds are “unsafe” and inconvenient as they require an override that may or may not be correct. I propose that the method gets a magic type just like require and typeof have, so that:
game:QueryDescendants("LuaSourceContainer") --> {LuaSourceContainer}
Another example:
game:QueryDescendants("LuaSourceContainer,Model") --> {LuaSourceContainer | Model}
For cases where regular string is passed, the return type should fallback to {Instance}.
local x: string = "hello"
game:QueryDescendants(x) --> {Instance}
Indirect string literals should also be supported, as when combined with type functions, it would create powerful system for frameworks and libraries.
local x: "BasePart,Model" = "BasePart,Model"
game:QueryDescendants(x) --> {BasePart | Model}