INDEX
はじめに
![](https://techlog.site/wp-content/uploads/2024/02/nwe_icon.jpeg)
初めてのTypeScriptを読みました。
その学習を記録します。
![40036_learning_typescript_cvr](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
![40036_learning_typescript_cvr](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
結論
interface 呼び出しシグネチャ名 {
(引数名1: データ型, 引数名2: データ型): データ型;
}
使い方
1. 型を使わない
const add = (x, y) => x + y;
2. 引数と戻り値のそれぞれに型定義
const add = (x: number, y: number): number => x + y;
3. 呼び出しシグネチャで型定義
interface CallSignature {
(x: number, y: number): number;
}
const add: CallSignature = (x, y) => x + y;
console.log(add(2,5));
実行結果を確認する
7