Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic function with two or more types cannot infer type provided as function parameter #49849

Closed
HaukeSchnau opened this issue Jul 10, 2022 · 2 comments

Comments

@HaukeSchnau
Copy link

Bug Report

πŸ”Ž Search Terms

  • infer generic type
  • multiple type parameters

πŸ•— Version & Regression Information

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

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const doSomething = <B,>(argB: B) => {};
doSomething("foo"); // Works as expected

const doSomethingElse = <A, B>(argB: B) => {};
doSomethingElse<"bar">("foo"); // Error: Expected 2 type arguments, but got 1

πŸ™ Actual behavior

TypeScript throws an error in the second example despite being able to infer the type in the first one

πŸ™‚ Expected behavior

No error, TypeScript infers the second type as "foo", since it is provided as an parameter

@MartinJohns
Copy link
Contributor

MartinJohns commented Jul 10, 2022

This is working as intended / a design limitation. Type argument inference is all or nothing. You want #26242 / #26349.

@HaukeSchnau
Copy link
Author

Alright, thanks for the heads up :)
Will follow the issue and PR

@HaukeSchnau HaukeSchnau closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants