GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — type infer from generic function · Issue #32170 · microsoft/TypeScript

type infer from generic function #32170

New issue
Copy link
New issue
Copy link
Closed
Closed
type infer from generic function#32170
Copy link
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code

Description

@Pomar81
Serhii Pomaraiko (Pomar81)
opened on Jun 28, 2019
Issue body actions

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:

Activity

  1. RyanCavanaugh commented on Jul 2, 2019

    @RyanCavanaugh
    Ryan Cavanaugh (RyanCavanaugh)
    on Jul 2, 2019
    Member
    More actions

    This is working as expected. There's no relation between the two Ts in test's declaration; i.e. you could equally have written

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

    I expect what you're trying to do is refer to a specific call instantiation of a generic function, which isn't currently possible.

    Reacted by owl from hogvarts
  2. Ryan Cavanaugh (RyanCavanaugh)
    added
    QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
    on Jul 2, 2019
  3. Pomar81 commented on Jul 4, 2019

    @Pomar81
    Serhii Pomaraiko (Pomar81)
    on Jul 4, 2019
    Author
    More actions

    Yes, I wanted to refer to specific call instantiation of a generic function
    e.g
    genericFC<'div'>

  4. TypeScript Bot (typescript-bot)
    closed this as completedon Jul 13, 2019
  5. ahejlsberg commented on Jan 27, 2022

    @ahejlsberg
    Anders Hejlsberg (ahejlsberg)
    on Jan 27, 2022
    Member
    More actions

    With #47607 it is possible to refer to specific instantiations of generic functions.

  6. microsoft
    locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in codeAn 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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.