How to type check a requiring module

Hey there, I haven’t really used typechecking in roblox yet. So I am pretty bad at it. I am working on a script but while requiring my module I am having a hard time defining a type to the variable that requires the module. Here is the code thus far:

--// Services
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

--// Modules
local Modules: Folder = RS.Modules
local BigNum = require(Modules:FindFirstChild("BigNum"))
local Formatter = require(Modules:FindFirstChild("Formatter"))

local function IsLessThan(n1: number | string, n2: number | string)
	local Big1 =
	local Big2 =

	return, Big1)

local function SetText(Label: TextLabel, NewVal: string)
	if IsLessThan(999, NewVal) then
		Label.Text = NewVal
		Label.Text = Formatter.Format(tonumber(NewVal), 2)

Also, how would I specify the type of a

1 Like

I believe you can use the Module.Type syntax. Type checking - Luau
So for example in your implementation of arbitrary/multi- precision module, you can use BigNum.BigNum (or BigInt or mpz_t or whatever you call it) for the script that requires the BigNum module.

You can use something like export type BigNum = typeof( with ... being the arguments to the function which you can put in the BigNum ModuleScript.

For example.
Module Script for BigNum

export type BigNum = typeof(
return BigNum

Script that requires BigNum

local BigNum = require(--[[BigNum ModuleScript]])
-- Now this local variable is the BigNum type from the BigNum module.
local bignumvalue: BigNum.BigNum =
1 Like

Thanks I’ll check this all out in a second

Ok well that seems to work great.