반응형
    
    
    
  TypeScript 강한 이유는 Aliases 있어서 이다
Type Aliases
  type Text = string;
  const name: Text = 'sein';
  const address: Text = 'korea';
  type Num = number;
  type Student = {
    name: string;
    age: number;
  };
  const student: Student = {
    name: 'sein',
    age: 12,
  };직접 원하는 타입을 정의 할수 있으며 새로운 타입을 정의 할 수 있다
type으로 Text 라는 string이라는 타입을 만들 수 있다
String Literal Types
  type Name = 'name';
  let seinName: Name;
  seinName = 'name';
  type JSON = 'json';
  const json: JSON = 'json';
  type Boal = true;타입을 문자열로도 지정 할 수 있다.
type Name 이라는 타입은 name 으로 지정할수 있다
이렇게 되면 무조건 name 할당 할 수 있다
반응형
    
    
    
  'Node > TypeScript' 카테고리의 다른 글
| 8.Intersection (0) | 2021.04.17 | 
|---|---|
| 7.Union (0) | 2021.04.17 | 
| 5.배열 Array or Tuple (0) | 2021.04.15 | 
| 4.함수 타입(JS →TS) (0) | 2021.04.15 | 
| 3.기본 타입(2) (0) | 2021.04.14 | 
 
                    
                   
                    
                   
                    
                  