Skip to content

Typescript failed to expand type in generic for unknown reason #28545

Open
@mmis1000

Description

TypeScript Version: 3.1.3

Search Terms:

Code

type Or<T> = T [
    {
        [K in keyof T]: T[K] extends ((...arg:any[])=>any)?
            never:
            K
    } [keyof T]
]

// F is unknown
type F = Or<[
    string,
    number
]>

// F_ is string|number
type F_ = ([
    string,
    number
])[
    {
        [K in keyof ([
            string,
            number
        ])]: ([
            string,
            number
        ])[K] extends ((...arg:any[])=>any)?
            never:
            K
    } [keyof ([
        string,
        number
    ])]
]

Expected behavior:
I will get the type string|number for both case

Actual behavior:
The generic failed to expand the type and make F as unknown for unknown reason,
while manully inline it in F_ typed as expected

Playground Link:
link
Related Issues:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional types

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions