4.7 인터페이스와 클래스의 관계
인터페이스와 클래스가 서로 어떤 방식으로 의존할 수 있는지에 대해 이야기한다.
클래스의 인터페이스 구현
interface Animal {
legs: number;
}
class Dog implements Animal { }error TS2420: Class 'Dog' incorrectly implements interface 'Animal'.
Property 'legs' is missing in type 'Dog'.interface Animal {
legs: number;
}
class Dog implements Animal {
legs: number = 4;
}
// Okay인터페이스의 클래스 확장
Last updated