LoginSignup
1
0

More than 1 year has passed since last update.

[TypeScript・Vue3] この呼び出しに一致するオーバーロードはありません....

Posted at

環境

Vue3 × Typescript × Element Plus

message

  • この呼び出しに一致するオーバーロードはありません。
    前回のオーバーロードにより、次のエラーが発生しました。ts(2769)
  • runtime-core.d.ts(962, 25): 前回のオーバーロードはここで宣言されています。

原因

  • 外部のコンポーネントを使うときにおこりやすい?
  • どこかしらの型が間違っている。

ts-overload-notfound.png
ts-overload-notfound-2.png

型定義元を見てみると、

// ...
export declare const inputNumberEmits: {
    change: (prev: number | undefined, cur: number | undefined) => boolean;
    blur: (e: FocusEvent) => boolean;
    focus: (e: FocusEvent) => boolean;
    input: (val: number | null | undefined) => boolean;
    "update:modelValue": (val: number | undefined) => boolean;
};
// ...

となっており、inputイベントの引数はnumber|null|undefinedの三種類である。

// ...
const onChange = (value: number) => { ...
// ...

しかし、定義した関数はnumberのみとなっていたために、エラーとなっていた。

解決

onChange関数の引数を (value: number|null|undefined)とすると、エラーが消えた。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0