question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Argument becomes implicit any when a void-returning overload follows a non-void-returning signature

See original GitHub issue

Bug Report

🔎 Search Terms

overload argument type signature

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about overloads (and #48077)

⏯ Playground Link

Playground link with relevant code

💻 Code

declare const it: {
    (test: () => Promise<void>): void;
    (test: (input: string) => void): void;
}

it((input) => {
    input.toUpperCase();
});

it(async () => {
    // ..
});

🙁 Actual behavior

Error: Parameter 'input' implicitly has an 'any' type.

🙂 Expected behavior

No type error. The input parameter is type string and should be resolved as such.

For more context, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59075.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanCavanaughcommented, Mar 3, 2022

The problem is that we assign a contextual type during overload resolution, and don’t have an acceptable way to “undo” that. Prior attempts to fix this have failed for one reason or another.

See also #11936

1reaction
JoshuaKGoldbergcommented, Mar 3, 2022

Hmm, now that #29374 is in I was looking forward to making another multi-year pull request. Great…!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Considerations in Overloading Procedures - Visual Basic
When you overload a procedure, you must use a different signature ... by all languages, and parameter arrays are limited to Visual Basic....
Read more >
Immutable objects
It is defined by an accessor method: A zero argument, non- void -returning Java method. No annotations are required on abstract accessor methods...
Read more >
Proposal: allow absl::FunctionRef - Google Groups
I'm not sure I follow how the argument for absl::FunctionRef is different from the arguments presented in the std::function thread.
Read more >
Morphing: Structurally Shaping a Class by Reflecting on Others
the following code iterates over the public, non-void-returning methods of X, ... over all non-void returning method of the type parameter X ....
Read more >
Structural Abstraction A Mechanism for Modular Program ...
non-void-returning methods of X, such that there is also some method in X with the same name, taking no argument: <R,Y*>[meth]for ( public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found