In a project I wish to dynamically require ModuleScripts that are a child of another ModuleScript:
for _, child in script:GetChildren() do
if not child:IsA("ModuleScript") then continue end
local tutorial = require(child)
if tutorial.Name and tutorial.Enabled ~= false then
tutorials[tutorial.Name] = tutorial
end
end
This script is marked with --!strict, and hovering over the require() call gives a Type Error: Unknown require: unsupported path.
The argument is correctly typed as a ModuleScript but the typechecker doesn’t like an argument it can’t statically fetch.
This occurs with and without the new Luau type solver (which btw just completely fails on large place files so I can’t even use it).
Repro place file using FindFirstChildWhichIsA:
Unknown require bug.rbxl (57.0 KB)
Expected behavior
No type error should occur if it is passed a ModuleScript instance.
