-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Weird post-hoc inferrence in function types generated from $Call? #8838
Copy link
Copy link
Closed
Labels
incompletenessSomething is missingSomething is missing
Description
Flow version: 0.171.0
Expected behavior
I'd expect both of these snippets of code to generate the same error, but only the normal generic errors, the $Call generated one does not:
type ToFunction<Parameter> = (x: Parameter) => string;
declare var expectString : ToFunction<string>;
expectString(10); // Correctly gives me an error
type _ToFunctionFromCall = <Parameter> (Parameter) => (x: Parameter) => string;
type ToFunctionFromCall<Parameter> = $Call<_ToFunctionFromCall, string>;
declare var expectStringFromCall : ToFunctionFromCall<string>;
// Does not give me an error, instead changes type of `expectStringFromCall`
// to (string | number) => string;
expectStringFromCall(10); I need the call version because I am passing it to $ObjMap. Currently, the $ObjMap appears like it's working, as hovering over the resultant types shows me what I expect to see ({ a: number => string, b: boolean => string, etc. }). Yet the second I try to use any of them, it just changes their parameter types to accept anything I pass to them.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
incompletenessSomething is missingSomething is missing