<aside> 📌 값 자체가 타입인 리터럴 타입
</aside>
let str: 'hello' = 'hello';
str = 'world'; // Type '"world"' is not assignable to type '"hello"'
const
를 사용하면 됨const obj: { name: 'zero' } = { name: 'zero' };
{ name: string }
{ name: 'zero' }
로 지정함const arr: [1, 3, 'five'] = [1, 3, 'five'];
(string | number)[]
[1, 3, 'five']
로 지정함const func: (amount: number, unit: string) => string
= (amount, unit) => amout + unit;
(amount: number, unit: string) => string
로 지정
<aside>
📌 as const
라는 특별한 접미사를 붙이면 값을 바꿀 수 없다. (read-only)
</aside>
const obj = { name: 'Lee' } as const;
obj.name = 'Kim'; // Cannot assign to 'name' because it is a read-only property.