Я пытаюсь расширить абстрактный общий класс, но у меня возникают проблемы с расширением некоторых методов.
Учти это:
abstract class A<T,K> {
protected abstract upload<S>(item: T): S
protected abstract download(item: T): K
}
class B<T, K > extends A<T, K>{
protected upload(item: T):string {
return 'hello'
}
protected download(item: T): number{
return 1
}
}
Ошибка, которую я получаю для метода upload
в классе B
:
Property 'upload' in type 'B<T, K>' is not assignable to the same property in base type 'A<T, K>'.
Type '(item: T) => string' is not assignable to type '<S>(item: T) => S'.
Type 'string' is not assignable to type 'S'.
для метода download
в классе B
:
Property 'download' in type 'B<T, K>' is not assignable to the same property in base type 'A<T, K>'.
Type '(item: T) => number' is not assignable to type '(item: T) => K'.
Type 'number' is not assignable to type 'K'.
'number' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'.