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 methods are not properly inferred when used as a value #5251

Closed
david-driscoll opened this issue Oct 14, 2015 · 2 comments
Closed

Generic methods are not properly inferred when used as a value #5251

david-driscoll opened this issue Oct 14, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@david-driscoll
Copy link

I think I have noticed a problem with Generic Methods, not properly inferring their types, when they are used as a value, instead of as a method. I'm not sure if it's a known issue or not.

It's easy enough to work around by using a function, but I'd prefer to just hand in the method, since it's already a method that can be called.

This case is in Rx, but I've seen other examples of it too.

var observableOfAny = Observable.from(items)
    .flatMap(Observable.from); // using as a variable doesn't work

var observableOfString = Observable.from(items)
    .flatMap(x => Observable.from(x)); // Using a delegate works

var fromString: (arr: string[]) => Observable<string> = Observable.from;
var observableOfString = Observable.from(items)
    .flatMap(fromString); // Properly casting the method works

I've got an example, again using rx interfaces (so maybe something is wrong with them? it's possible). playground example

@mhegazy
Copy link
Contributor

mhegazy commented Nov 13, 2015

This is a duplicate of #3410. also see #5616 (comment).

@mhegazy mhegazy closed this as completed Nov 13, 2015
@mhegazy mhegazy added the Duplicate An existing issue was already created label Nov 13, 2015
@mhegazy
Copy link
Contributor

mhegazy commented May 18, 2017

tracked by #5616

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants