Port minor typeannotation fix

Backport of minor (community contributed) fix #15312 (from `master`)