Allow for non-static module typechecking

Currently, you’re unable to require a module with a non-static value, which is a pain when it comes to developing modules which would benefit from type-checking on modules.

Take this function for example:

-- Custom Service Module
function module:GetService(Service: string)
    return require(script.Services[Service])
end

When running this, you will not get any type-checking when attempting to reference the service required from this function.

However if you were to do this instead you would get type-checking when referencing the required module:

function module:GetPlayerService()
    return require(script.Services.PlayerService)
end

Allowing dynamic type-checking would improve the developer experience for almost all programmers on Roblox as it would make the work for them much easier and would allow for many more open-source modules to be made which would utilize type-checking (for example; game frameworks).

Thank you,
Starnamics

7 Likes

This may be related:

I’ve actually been working on a framework that tries to be more type-checker friendly in this area. My design idea is to be more reliant on the hierarchy for getting providers rather than using a wrapper, which ends up being easier for the checker to decipher but comes at the cost of restricting how much each provider can interact with each other along with how I structure client-server communication.

In all, this is pretty much a necessary evil.

I don’t entirely believe so as that feature requests seems to be asking for a different feature.

I 100% agree, if Visual Studio Code can provide type-checking for such things, why can’t Roblox Studio? It’d make developing & using modules so much easier.

See Strings should be literally inferred where possible · Issue #613 · Roblox/luau · GitHub as I believe whats happening here is Luau being luau with strings

1 Like