Code Fix

中級No overload matches this call の原因と直し方 › パターン2

No overload matches this call の原因と直し方

複数のシグネチャ(オーバーロード)を持つ関数を、どの組み合わせにも当てはまらない引数の型で呼び出したときに出るエラーです。

 1  function merge(a: string[], b: string[]): string[];
 2  function merge(a: number[], b: number[]): number[];
 3  function merge(a: any, b: any): any {
 4    return a.concat(b);
 5  }
 6  console.log(merge(_____________));
                            ^
main.ts(6,28): error TS2769: No overload matches this call.

空欄を埋めてコンパイルを通す

広告
広告スロット(未設定)

No overload matches this call の原因と直し方

エラーメッセージには、試したすべてのオーバーロードでの失敗理由が列挙されます。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)