Issue
interface BaseInter{
name : string;
test();
}
abstract class Abs implements baseInter{
}
In TypeScript, compiler complaints that the class incorrectly implements the interface:
name is missing in type abs.
Here Abs
is an abstract class and so why do we need to implement the interface over there?
Solution
You need to re-write all of the members/methods in the interface and add the abstract
keyword to them, so in your case:
interface baseInter {
name: string;
test();
}
abstract class abs implements baseInter {
abstract name: string;
abstract test();
}
There was a suggestion for it: Missing property declaration in abstract class implementing interfaces but it was declined for this reason:
Although, the convenience of not writing the declaration would be nice, the possible confusion/complexity arising from this change would not warrant it. by examine the declaration, it is not clear which members appear on the type, is it all properties, methods, or properties with call signatures; would they be considered abstract? optional?
Answered By - Nitzan Tomer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.