-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead
Description
declare var f: {
<U>(x: U): U,
};
declare function pipe<T>(arg: T, dit: (arg: T) => T): T; // welkom in F#!
declare function apply<V>(dit: (arg: V) => V, arg: V): V;
let n = pipe(12, f);
let m = apply(f, 12);n: number as desired but m: {}. It looks like, during the second pass of type parameter inference for apply, the call signature is inferred from dit's argument before it is inferred from arg. Since f is itself generic, the default is {}. @ahejlsberg, is this intended behaviour? It seems like a bug to me.
Also I am not sure why getSingleCallSignature special-cases single-call-signature-only objects. You get yet a different result if you have an extra property on f:
declare var f: {
<U>(x: U): U,
hunch(x: number): number
};
...
let n = pipe(12, f)
let m = apply(f, 12)Now both n: any and m: any because getSingleCallSignature doesn't return a signature, so instantiateTypeWithSingleGenericCallSignature doesn't do its instantiation at all.
Metadata
Metadata
Assignees
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead