How do you type cast require()?

If I am requiring a module, what type is returned?

local module: ModuleScript = require( seems incorrect because ModuleScript is an instance which would be and not what require actually returns AFAIK

The documentation explains it as the variable being directly set to the table that was returned, in that case would I just cast it to the format of the table?

1 Like

require basically turns the module into what it returns.


return "hi"


local msg = require(
print(msg) --> "hi"
1 Like

They’re asking about the typing of module scripts, not what require does.

To OP, I believe that at least for functions, it automatically handles the types for them, but I can’t get it to work with other table entries like strings.


You don’t need to set the type to get autocomplete, which I think is what you’re using the type for.

Yes. The require is the type of whatever the module script returns.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.