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

want a type operator that converts a function type to the type of one of its parameters #19125

Closed
fc01 opened this issue Oct 12, 2017 · 2 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@fc01
Copy link

fc01 commented Oct 12, 2017

//Type A ----> Type B

type A = (state: string, action: any) => string
type B = string


//SyntaxError
type GetB<K extends (state: S, action: any) => S, S ???? > = S 
type xxx = GetB<A>  


//right
const getB = <S>(f: (state: S, action: any) => S) => ({} as S)
let b = getB({} as A) //string
@jcalz
Copy link
Contributor

jcalz commented Oct 12, 2017

I think a little prose would be helpful for people trying to understand what you're asking.

If I read you correctly, you want a type operator that converts a function type to the type of one of its parameters. That's not currently possible, although #6606 would presumably let you do this:

type Param1<T extends Function> =
  typeof (null! as <P=never>(f: (p1: P, ...rest: any[]) => any) => P)(null! as T);
type xxx = Param1<A>

So this is either a duplicate of #6606 or a new request that could be tracked in #16392, maybe? Not sure.

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Oct 12, 2017
@fc01 fc01 changed the title arrow function type mapped type want a type operator that converts a function type to the type of one of its parameters Oct 13, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 27, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Oct 27, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants