Type hint on behalf of @alxy

@alxy tried to do something similar in #3287.