中級 › No overload matches this call の原因と直し方 › パターン4
No overload matches this call の原因と直し方
複数のシグネチャ(オーバーロード)を持つ関数を、どの組み合わせにも当てはまらない引数の型で呼び出したときに出るエラーです。
1 function joinVals(a: string, b: string): string; 2 function joinVals(a: number, b: number): number; 3 function joinVals(a: any, b: any): any { 4 return a + b; 5 } 6 console.log(joinVals(______)); ^
main.ts(6,13): error TS2769: No overload matches this call.
空欄を埋めてコンパイルを通す
joinValsはstring同士かnumber同士の組み合わせしか受け付けません。
次の問題