How to fix Cannot use optional operator '?' with mapped type key in TypeScript | DevErrors