<aside> 📌 타입을 값으로 쓸 수는 없고, 값을 타입으로는 쓸 수 있거나/ 없거나
</aside>
const title: 'Lee' = 'Lee';
const title: 'Lee' = 'Lee';
const myName: title = 'Lee'; // 'title' refers to a value, but is being used as a type here.
특정 변수와 동일한 타입을 사용하고 싶다면 typeof
를 붙일 것
const title: 'Lee' = 'Lee';
const myName: typeof title = 'Lee';
const date: Date = new Date();
const math: Math = Math;
class Person {
name: string;
constructor(name: string) {
this.name = name;
}
}
const person: Person = new Person('Lee');