Support nullable params and returns in generated externs

Fixes #2642.