-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Closed as not planned
Copy link
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options
Description
🔎 Search Terms
override method compiler error confusing message Target signature too few
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Why are functions with fewer parameters assignable to functions that take more parameters?
⏯ Playground Link
💻 Code
declare class Foo {
method(): void
}
declare class Bar extends Foo {
override method(arg: number): void
// ~~~~~~
// Error! Target signature provides too few arguments. Expected 1 or more, but got 0.
}🙁 Actual behavior
An error message explains how base class has less arguments than expected
🙂 Expected behavior
An error message explains how derived class has more arguments than expected
Additional information about the issue
I understand that the compiler can't know whether the base class or the derived class is defined incorrectly. But:
- normally, deriving from a class means that the developer wants to encapsulate the scope of work within this class and avoid changing the base class; also
- seeing an error related to base class on a method of the derived class is unexpected and confusing.
Metadata
Metadata
Assignees
Labels
Not a DefectThis behavior is one of several equally-correct optionsThis behavior is one of several equally-correct options