You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to move modulescripts when running but keep typechecks.
- What is the issue? Include screenshots / videos if possible!
Dynamic require
s cannot be typechecked.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried casting the dynamic require to a static require (one that only works before running)
--!strict
local module = require(game.ReplicatedStorage.movedAndRenamedModule) :: typeof( require(script.Parent.module) )
(With this it thinks that module
is any
)
But the typeof( require(script.Parent.module) )
works as expected when I use it to type a variable
--!strict
local var: typeof( require(script.Parent.module) ) = {}
--Table type 'var' not compatible with type '{| new: () -> () |}' because the former is missing field 'new'
On the devforum I found nothing about this problem, but based on the typechecking resources I found my solution should work. (luau-lang.org) (devforum: Type checking for beginners!)