K
K
Konstantin2018-07-09 18:50:33
typescript
Konstantin, 2018-07-09 18:50:33

How to override a method from an abstract TypeScript class?

The abstract class has a method:

public prop<K extends keyof RootObject>(key: K) {
    return this._has(key) ? this.data[key] : null;
 }

I tried to override it in the descendant classes:
public prop<K extends keyof IParentProfile>(key: K) {
    return this._has(key) ? this.model[key] : null;
  }

But it doesn't work, IDE writes incompatible override

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question