Inflearn Community Q&A
No author
This post's author information has been deleted.
interface에 readonly 속성이 있을 때
Written on
·
350
0
interface A {
readonly a: string;
b: string;
}
class B implements A {
a: string = '123'; // OK
b: string = 'world';
}
const b: B = new B();
b.a = '456'; // OK
console.log(b); // { a: '456', b: 'world' }
인터페이스 A에서 변수 a는 readonly 키워드가 붙어있는데 이를 구현한 클래스 B에서 readonly 키워드를 붙여주지 않아도 에러가 발생하지 않는 이유가 궁금합니다.
interfacetypescriptclass
Quiz
TypeScript의 주된 목적은 무엇일까요?
자바스크립트 코드 실행 속도 향상
브라우저 호환성 자동 해결
변수, 매개변수, 리턴값에 타입을 부여하여 안정성 확보
CSS 스타일 자동 생성





