[Fix] Fixing previous incorrect removal of using typeof

- When checking a value to not be "undefined", should be using `typeof` which I previously was but incorrectly removed when doing cleanup/optimizations