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