Closed
Description
TypeScript Version: 3.4.0-dev.201xxxxx and 3.3.3333
Search Terms: enum, record
Code
declare function enumValues<K extends string, V extends string>(
e: Record<K, V>): V[];
enum E {
A = 'foo',
B = 'bar'
}
let x:E[] = enumValues(E);
Expected behavior:
No type error, because K is inferred to be 'A' | 'B'
and V
is inferred to be 'foo' | 'bar'
.
Actual behavior:
Type error after TS 3.3:
error TS2322: Type 'string[]' is not assignable to type 'E[]'.
It appears that K
and V
are chosen to be the lower bound string
.