직접 원하는 타입을 정의해서
1. type Text = string;
2. type Num = number;
3. type Student = {
name: string;
age: number;
};
사용할 수 있음
1. const name: Text = 'ellie';
2. const address: Text = 'korea';
3. const student: Student = {
name: 'ellie',
age: 12,
};
String Literal Types
타입을 문자열로 지정할 수 있음
type Name = 'name';
let ellieName: Name;
ellieName = 'name';
type JSON = 'json';
const json: JSON = 'json';
'Type script' 카테고리의 다른 글
Enum Type (0) | 2021.04.17 |
---|---|
Intersection Type (0) | 2021.04.15 |
Union Type (0) | 2021.04.15 |
함수 정의 방법 (0) | 2021.04.13 |
Typescript 기본타입 (0) | 2021.04.13 |
댓글