Microsoft/TypeScript

Diagnostic for incompatible overload signature doesn't explain why

Open

#48,186 创建于 2022年3月9日

在 GitHub 查看
 (1 评论) (6 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: Error MessagesHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

Bug Report

🔎 Search Terms

function incompatible overload implementation signature assignability TS2394

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about function overloads

⏯ Playground Link

Playground link with relevant code

💻 Code

function example(overloaded: string): string;
function example(actual: number, option?: boolean): string {
  return `${actual}${option}`;
}

🙁 Actual behavior

A single line of error message that doesn't indicate which parameter or return type is the issue.

function example(overloaded: string): string;
//       ~~~~~~~
// Error: This overload signature is not compatible with its implementation signature.

🙂 Expected behavior

Can we elaborate on that error message with the first assignability issue?

Bikeshedding on the error message specifics welcome...

function example(overloaded: string): string;
//       ~~~~~~~
// Error: This overload signature is not compatible with its implementation signature.
//   Overload parameter 'overload: string' is not assignable to implementation parameter 'actual: number'.

贡献者指南