You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useFunct(f1,(param)=>{// expect param to be of type string inferred from f1// it's of course a function, and not the value of the functionreturn{
param
}})
is it possible or it needs an implementation? if not, I think it would be like returnOf keyword (like keyof)
well I'm most interested in using the return value of the function, the function parameters can be already be inferred (with the interface and multiple arguments generics), it's a simpler case I think, an extra keyword, not HKTs, like typeof works on plain function definitions, and you get it's "type" so you can put it on an interface
EDIT: now that I'm writing this, I remembered I wrote about something like this in #12497, getting the result of the constructor is the same goal, so it would make things really easy for typed constructors / factories as well
Not sure if this is already possible with Typescript or it's being discussed (I can't even think about the keywords for the search).
Suppose I have a type defines a function that returns a generic:
I then accept it as a parameter in a function, inferring it's return value:
when
funct
is called, it then returns a new 'partial' function that returns a wrapped object:I want to pass this
f1
variable to another function, and it'll know the parameter type by inferring it (again):then when doing:
is it possible or it needs an implementation? if not, I think it would be like
returnOf
keyword (likekeyof
)The text was updated successfully, but these errors were encountered: