Https://Www.Typescriptlang.Org/Play?#Code/C4TwDgpgBAsiAq5oF4oDsCuBbARhATlAD5QDOw+AlmgObFQ4D2jANhAIZr2Ysv0ZoAJhABm1CIPoAKKQDp5nEAEF8NUgC4oigNoBdAJRRkAPigCA1mkYB3NIZIBvKNvMQQm8lVq7NigDRQAPqBWOz4rviBYPiMYMEA-JoAogAeAMYsGMIAPHCIkAEUGBCmAL4A3ABQlaCQsCAA8jgAVhBpwPkoUA6VUH1QIsyamLgEVf0MYR4U1DRVFZVpjGjkUFiNLW3AmnBNre2dRt0DQ1AATAE4U1AARGc3UAvVtdAAShCelO0Se1uHqD0JsFQuECFEYnFApomKwOGhxv1Boxpl45pVSotlqt8B8KL92kcnMCwhFwbFgpoihAAkjNHcHk8litgFBhGANPVOnojtpelAAIx+Pn0oV9Kmi9AYXgSgTCMRoCQSokhElg6LkqFQcVkRhYCB0wTsYDsBkBAD0Zqg1AAbuwWJRJLbMtA+VIwjQUbMAq5zNZhtg8PhDCZbsBcTchboqpiVrDZCxGDQpGzSPpykA
Как-То так? Но тип рекурсивен в таком случае. Не уверен