You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--!strict
local ClassName = {}
ClassName.__index = ClassName
function ClassName.new()
local self = setmetatable({}, ClassName)
self._privateProperty = nil :: Vector3?
return self
end
type ClassName = typeof(ClassName.new())
-- doc comment vector2
function ClassName.OverloadVector2(self: ClassName, value: Vector2): Vector2
return value
end
-- doc comment vector3
function ClassName.OverloadVector3(self: ClassName, value: Vector3): Vector3
return value
end
ClassName.Overload = function(self: ClassName, arg1: any): any
if typeof(arg1) == "Vector2" then
return self:OverloadVector2(arg1)
elseif typeof(arg1) == "Vector3" then
return self:OverloadVector3(arg1)
end
error("Arguments did not match any overload.")
end
:: typeof(ClassName.OverloadVector2)
& typeof(ClassName.OverloadVector3)
Usage 1:
local className = ClassName.new()
local raycastResult = workspace:Raycast(Vector3.new(), Vector3.new())
if raycastResult then
local v3r = className:Overload(raycastResult.Position)
Vector3.new():Lerp(v3r, 1);
end
Type Error: Type 'Vector2' could not be converted into 'Vector3'
Replacing raycastResult.Position with raycastResult.Position :: Vector3 removes the error, but should not be necessary. Hovering the cursor over v3r displays the type as Vector3 regardless of whether this casting is done.
When an overload is called with a colon syntax, placing the I-cursor inside the function will always display the first overload.
The text was updated successfully, but these errors were encountered:
Implementation:
Usage 1:
Type Error: Type 'Vector2' could not be converted into 'Vector3'
Replacing
raycastResult.Position
withraycastResult.Position :: Vector3
removes the error, but should not be necessary. Hovering the cursor overv3r
displays the type as Vector3 regardless of whether this casting is done.When an overload is called with a colon syntax, placing the I-cursor inside the function will always display the first overload.
The text was updated successfully, but these errors were encountered: