DataType Math
Roblox features a bunch of "DataType" classes and many of these use operator overloading for math operations. i.e. Vector2
, Vector3
, CFrame
Unfortunately, TypeScript does not have a way to describe operator overloading with types.
To get around this, roblox-ts adds four macro methods .add()
, .sub()
, .mul()
, and .div()
to DataType classes which support math operators.
a.add(b)
compiles toa + b
a.sub(b)
compiles toa - b
a.mul(b)
compiles toa * b
a.div(b)
compiles toa / b
You can see an up to date list of classes which support math operators here.