SI-7163 backport of annotated retyping to 2.10.1

Backport of #2118 to 2.10.1.

Tracking this with a retrospective ticket SI-7163

Review by @JamesIry