Trying to override a method in a child class, with a generic return type, and coming up with this error. I've been reading could be instantiated with a different subtype of constraint 'object' but I can't wrap my ahead around to my scenario. Any advise?
Type '{ deployments: { [deploymentId: string]: string[]; }; }' is not assignable to type 'SomeInterface'.
'{ deployments: { [deploymentId: string]: string[]; }; }' is assignable to the constraint of type 'SomeInterface', but 'SomeInterface' could be instantiated with a different subtype of constraint '{}'.(2322)
class SomeClass {
testGenericMethod<T>(): T {
throw new Error('Implement this.')
}
}
interface SomeInterface {
deployments: { [deploymentId: string]: Array<string> }
}
class ImplementSomeClass extends SomeClass {
testGenericMethod<SomeInterface>(): SomeInterface {
const deployments: { [deploymentId: string]: Array<string> } = {}
return { deployments }
}
}