Вот вся реализация в playground, все типы выводятся как надо
https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgzgUQLZlAeQEYCsIGNgA8mWAfFALwCwAUFFANoDWEIA9gGZTEC6UEAHsAgA7ACZwGwiADcIAJ14B+KMDkBXaAC4o7AIYAbOBBo1QkKAn659a0RADSLOAHUAlsAAWAFXAQ07Ai8AGigANTJyKABvGjp6eyhXYShmNk4vbgBaRW1La1sIQPjuELUxCHYkiFEyASExCVCoZSlZOShtewBuGgBfJhYOKAye6lNfCysbOwAhEB9IQJDwiigABVdcRiXJ-LtHEBd3b19-HfCSUfHzAFUwSDkAYV0jR49dOV18eQpYqAByACC-z+AB8ATMQbQoOD-o8oXRYQARBEwgEIVGwgBimIBAHFcf8ABKEmCEgBShPshIAMoSALKEgByhLQhLWhIAioSAEqEgDKhK8hJuhNChOchIAGoSAJqEgBa-1GZmgNNYAHd5LgXhA3h8vkJ2pF1Vq5DqjAQ7g9nq93p9vnJLtdoPqHUbVtb5La9fbDT9wabtbq3f65CZqKqoDy8Go5HBXLJ9CBLKpDWtdJ4M58kHBAnxBCJxFA4KokgBzIJ-LyA3C4Av1YvCNT6fRomO4VhyUQEUtyCshPsVkgRYYNosSAAGAHpNAASKJJdg-DNZg1IXrThdLn481zljzAXqTv7KKIMVKJZKrjzZ3RIbjaIfCctQXpQABk0dj8cTEGTqbujed65gQe4HsAIQ1nWJB-NoXjjg0UAzvOi7CMu7TAeux5-HQZ4XiwV7rJmt7ro+JZli+b64R0Y51BOyFblEz7lpu27obu+6Hjh0J0Hh364HGCZJimghASRIF5uBh5QbWuCwbxfHwYhxYzguLE8XxWnNMMck0Vpyn0Uhk6oTumESdhTFmdGXFHieinaTp54DCARFYTm5EsW+n4CUJf4AWJ6YWTmUm2bJMH6dphmFsZpkceZa45ppjnaco0H1l+zmXkkxGJfenmUa+vSRY50WNlO6mFWxaEYTZEHJSlqW+b+ImAUFeWgdJkG6RFDmNbR6VXJGEySVicisEgNxyPo+ZGcWLGjh2fmtY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