-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Inference of function pointer parameters for callback routines #16829
Comments
Your example contains a few typos. When they are fixed the example works. function map<T,R>(container: IterableIterator<T>, callback: (t: T) => R) : Array<R> {
return <any>null;
}
function foo() {
map(new Map<number, number[]>().values(), v => v[0]);
} |
Oh, that suddenly makes sense :) As you can see, I'm new to typescript. Is there any way |
|
I think I can't use that yet because I'm slowly migrating a JS project over, but I'll definitely turn that on when it becomes possible. If I have a function declared like this:
Is there anything sane I could do with |
TypeScript always expects parameters to have names for the sake of documentation, even if those parameters appear as part of a type. So if you type: function foo<T, R>(x: T, f: (t: T) => R): R { return f(x); }
foo(1, /*cursor*/ You'll get useful signature help. |
Thanks. |
I'm not sure if this is related to #15114, but I feel like it's a separate case.
Under Typescript 2.4.1, shouldn't type inference work here:
The type for callback parameter
v
is never inferred. I have to explicitly declare it:I don't see why the compiler can't figure this out from the typing of the
map
function?The text was updated successfully, but these errors were encountered: