We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
merge function param union
https://www.typescriptlang.org/play?#code/C4TwDgpgBAYgrgOwMYB4AqA+KBeKAKMAQwCdCBbALijQEocs0BuAWACgAbCYKAMyvmQoAzsGIBLBAHMsAH1iJUCOGQBGEYllx5CVQghB1sWQi1Y88ARhqmgA
type Func<T> = (param: T) => T; let f: Func<string> | Func<number> = (a: any) => a; f(1);
The following error appears in the "Errors" tab:
Argument of type 'number' is not assignable to parameter of type 'never'.
I'd expect the type of the function parameter be a union of the original types, just like it is done for the return type.
No response
The text was updated successfully, but these errors were encountered:
f might be a Func<string>, in which case it would receive a number.
f
Func<string>
number
Sorry, something went wrong.
Fair enough. I'll close this issue then. Thanks!
contravariance strikes again
No branches or pull requests
π Search Terms
merge function param union
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBAYgrgOwMYB4AqA+KBeKAKMAQwCdCBbALijQEocs0BuAWACgAbCYKAMyvmQoAzsGIBLBAHMsAH1iJUCOGQBGEYllx5CVQghB1sWQi1Y88ARhqmgA
π» Code
π Actual behavior
The following error appears in the "Errors" tab:
π Expected behavior
I'd expect the type of the function parameter be a union of the original types, just like it is done for the return type.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: