So I am making another module to be open-sourced and I am wondering if in my case, whether or not typechecking would be worth it. So far here is my code:
-- Typechecking
type Vector3<T> = { [Vector3] : T }
type Dict<T> = { [table] : T }
local pathfinder = {}
function pathfinder.new(Target : Instance, Endpoint: any, Type : string)
local Dictionary = {}
--//Endpoints
if typeof(Endpoint) == "Vector3" then
local Vector: Vector3<Endpoint> = { {Endpoint} }
Dictionary["EndpointType"] = Vector
elseif typeof(Endpoint) == "table" then
local Table: Dict<Endpoint> = { Endpoint }
Dictionary["EndpointType"] = Table
end
end
return pathfinder
Would this be worth using typechecks or would it be just a waste of performance. I read somewhere that it would reduce mistakes but I am not entirely sure if it would be useful in this specific case. If my code shouldn’t utilize typechecking in this way but instead a different way, please specify what changes I should make.