How to fix Type instantiation is excessively deep and possibly infinite in TypeScript | DevErrors