The performAfterDelay
function on timer will helpfully raise an error if you mistakenly pass a non-function argument for the callback.
timer.new
does not have the same effect and will instead continue on as though nothing occurred, allowing potential bugs to manifest.
Adding a function (and perhaps nil since that’s also a bug) check would improve the developer experience.
local t = timer.new(10, "hello") — no error
timer.performAfterDelay(10, "hello") — correctly throws an error