Typescript failed to expand type in generic for unknown reason #28545
Open
Description
opened on Nov 15, 2018
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