Fix : field.length undefined

fixes #519 (field.length undefined in typeCast function)