タイプエイリアスの復習
type Human = {
name: string;
age: number;
}
const human: Human = {
name: "Quill",
age: 38
}
let developer: Human;
Interfaceの定義
interface Human {
name: string;
age: number;
greeting(message: string): void;
}
const human: Human = {
name: "Quill",
age: 38,
greeting(message: string) {
console.log(message);
}
}
let developer: Human;
Interfaceで関数の型を定義する
interface addFunc {
(num: number, num2: number): number;
}
let addFunc: addFunc;
addFunc = (n1: number, n2: number) => {
return n1 + n2;
}