TypeScript에서 **readonly
**는 “읽기 전용(Read-Only)”을 의미하며, 주로 **프로퍼티(멤버 변수)**가 재할당되지 않도록 제한하기 위해 사용된다. 한 번 값을 할당하면 더 이상 수정할 수 없게 만들고자 할 때 활용할 수 있다.
eg. readonly
type FootballPlayer = {
readonly name : string,
age? : number
}
const son : FootballPlayer = {
name : 'son'
age : '29'
}
const kane : FootballPlayer = {
name : 'kane'
age : '28'
}
kane.name = 'winks'; // error
const player : [string,number,boolean] = ['son', 29 , true];