A method to perform branching while inferring types
TS Recursive Conditional Type
define type recursive conditional
TypeScript 4.5 performs some tail-recursion elimination on conditional types
it doesn't error even with deep recursion and optimizes by avoiding intermediate instantiations
Announcing TypeScript 4.5 Beta
Today we are excited to announce the beta release of TypeScript 4.5! To get started using the beta, you can get it through NuGet, or use npm with the following command: npm install typescript@beta You can also get editor support by Downloading for Visual Studio 2019/2017 Following directions for Visual Studio Code and Sublime Text 3.
https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#tailrec-conditional


Seonglae Cho