[TS] 함수 타입 표현식과 호출 시그니쳐

짱효·2024년 1월 29일
0

📖 TypeScript

목록 보기
18/20
post-thumbnail

함수타입 표현식

type Operation = (a: number, b: number) => number;

const add: Operation = (a, b) => a + b;
const sub: Operation = (a, b) => a - b;
const multiply: Operation = (a, b) => a / b;

  • 에러 발생

호출 시그니쳐(콜 시그니쳐)

type Operation2 = {
  (a:number, b: number): number;
}

const add2: Operation2 = (a, b) => a + b;
const sub2: Operation2 = (a, b) => a - b;
const multiply2: Operation2 = (a, b) => a / b;
profile
✨🌏확장해 나가는 프론트엔드 개발자입니다✏️

0개의 댓글