use `typeof` when checking if offset is defined