타입 추론하기


타입 추론하기

기본적인 타입 추론 let a = 'Mark'; // string const b = 'Mark' // 'Mark' => literal type let g = ['Mark', 'Haeun']; // string[] const h = ['Mark', 'Haeun']; // string[] const i = ['Mark', 'Haeun'] as const; // readonly ['Mark', 'Haeun'] Best common type let j = [0,1,null]; // (number | null)[] const k = [0,1,null]; // (number | null)[] class Animal {} class Rhino extends Animal {} class Elephant extends Animal {} class Snake extends Animal {} let i = [new Rhino(), new Elephant, new Snake()]; // (Rhino | ...


#TypeScript #타입스크립트 #타입추론 #타입추론하기

원문링크 : 타입 추론하기