typing: fixes failed cast when iterate over a nullable collection

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>