Skip to content

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

Closed
@fc01

Description

@fc01
//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

Metadata

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