I have the interface, base abstract class that implements this interface and some property in the Angular component that creates the new instance of the base class. This construction doesn't give me errors in the browser (perhaps because it is the JS that can stand anything), but I'm getting the TSLint error
TS2511:Cannot create an instance of the abstract class KitCustomizationBase
If I remove the abstract
word this error disappears. As I read in the TS documentation abstract class may content some implemented logic. Can someone explain it?
My interface:
export interface KitCustomizationInterface {
items: number[];
indexes: number[];
counter: number;
}
My base class (I'm getting the same error without the constructor):
import { KitCustomizationInterface } from '...';
export abstract class KitCustomizationBase implements KitCustomizationInterface {
public items: number[];
public indexes: number[];
public counter: number;
constructor(items: number[], indexes: number[], counter: number) {
this.items = items;
this.indexes = indexes;
this.counter = counter;
}
}
And the code from my component:
...
let k: KitCustomizationBase = new KitCustomizationBase([], [], 0);
...
Update
Notices for the duplicate markers:
- Angular has (because of the TS) different moments about the work with the interfaces.
- Moreover, we are talking about the specific TSLint error that doesn't have the results in the Google search.
- The link that duplicate markers gave, doesn't provide the explicitly answer. It's more like an answer "go read docs". Docs about what exactly?