Type Aliases

Type Aliases


1. Type Aliases : 원하는 타입을 지정하는 것

1. 변수처럼 타입의 별명을 지어줌
 
type Text = string;
 
const name: Text = 'kdn';
const address: Text = 'korea'
 
2. 객체에 들어갈 타입을 지정해줌
 
type Student = {
    name:string;
    age:number;
}
 
const student: Student ={
    name:'kdn',
    age:12,
}
  • String Literal Types : 값 자체를 타입으로 지정하는 것
type JSON = "json";
const json: JSON = "json";
 
console.log("json?", json);