Protect TypeCaster against null value, close #1321