We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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'.
'A' | 'B'
V
'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.
K
string
The text was updated successfully, but these errors were encountered:
T extends M
M
T[keyof T]
@ahejlsberg intended? Would like to understand before we publish the RC
Sorry, something went wrong.
I agree, should resolve to E[] and not string[].
E[]
string[]
ahejlsberg
Successfully merging a pull request may close this issue.
TypeScript Version: 3.4.0-dev.201xxxxx and 3.3.3333
Search Terms: enum, record
Code
Expected behavior:
No type error, because K is inferred to be
'A' | 'B'
andV
is inferred to be'foo' | 'bar'
.Actual behavior:
Type error after TS 3.3:
It appears that
K
andV
are chosen to be the lower boundstring
.The text was updated successfully, but these errors were encountered: