How to fix Type 'X' cannot be used as an index type in TypeScript | DevErrors