Forwarded Requires and Types

Lets say I have a module, that just indexes a module, requires it and returns it

so

--Index.lua
return require(script.ModuleA)

ModuleA has the type ‘TypeA’

I want to access ‘TypeA’ from the Index. Not from having to require the module myself.
But I can’t. Is there no way to do this in LuaU?

1 Like

You’ll have to re-export types to make them accessible from the root module.

local ModuleA = require(script.ModuleA)

export type TypeA = ModuleA.TypeA

return ModuleA
2 Likes

Yeah, I guess this is the only way then.

Damn that sucks.

It’s a hack but you can do this, it works for me with the old type solver:

type a = typeof(require(script.ModuleA))
return require(script.ModuleA) :: a

For some reason this doesn’t work even though it’s pretty much the same thing:

return require(script.ModuleA) :: typeof(require(script.ModuleA))
2 Likes

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