인터페이스

Interfaces 속성 이름과 객체의 값의 type을 나타내는 새로운 type을 만드는 것 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // 너무 긴 annotation const oldCivic = { name: 'civic', year: 2000, broken: true, }; const printVehicle = (vehicle: { name: string; year: number; broken: boolean; }): void => { console.log(`Name: ${vehicle.name}`); console.log(`Year: ${vehicle.year}`); console.log(`Broken? ${vehicle.broken}`); }; printVehicle(oldCivic); 인터페이스를 통해 간편하게 할 수 있다. ...

2023년 10월 5일 · 2 분 · 배준수