How to fix Type parameters for a generic type must be declared for use in a function implementation in TypeScript | DevErrors