I don't think it is necessary to use typeof here. It is enough to just do: if (lostCallback)