Вот более краткая версия проблемы: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAGzgcwBQEMBciDOUATjGGgJR6ElkDcAUKJLAiutnmCALYBGApkUqIufQQybR4SVJlwieAoogA+BYqQqIA3oiL8oIIkiy1EAXwb0ICQuppoAgmAAmAOUWD8iALyIA2gCMADSIAEyhAOSBkVFhkQC6VtSazu6eRPgAdMBwRACiWBAAFhgYKWQA8kQeYkK+AHxsmBVo1bVK5OQMQA