I have defined a type for a factory function where one of the functions returned uses a generic.
type Factory = (param: string) => {
func: <T extends {}>(param: string) => Promise<T>,
};
const factory: Factory = __factoryParam => ({
func: async <T>(__param) => {
return Promise.resolve({} as T);
},
});
When I hover over the __param parameter in the code above I get the error Parameter '__param' implicitly has an 'any' type.ts(7006).
If I get rid of the generic, then __param is typed correctly. If I explicitly type the parameter in the implementation, it of course works:
func: async <T>(__param: string) => {
What am I doing wrong here?