Skip to content

type infer from generic function #32170

Closed
@Pomar81

Description

@Pomar81

TypeScript Version: 3.5.1-3.5.2

Search Terms:
infer type from generic function

Code

type genericProps<T> = {
  abcId: string
  count: number
  flag: boolean
  className?: string
  as?: T
}


declare function genericFC<T>(props: genericProps<T>): any 

type test<T> = typeof genericFC extends <T>(props: infer P) => any ? P : never

Expected behavior:

 {
    abcId: string
    count: number
    flag: boolean
    className?: string
    as?: T
  }

Actual behavior:

{
   abcId: string
   count: number
   flag: boolean
   className?: string
   as?: unknown
 }

Playground Link: link

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions