Skip to content

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

Closed

Description

//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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions