Closed
Description
TypeScript Version: nightly (2.5.0-dev.20170621)
Code
const enum Test {
A = 'a',
B = 'b'
}
type TestMap = {[key in Test]: string}
// Type '{ [x: string]: string; }' is not assignable to type 'TestMap'.
// Property 'a' is missing in type '{ [x: string]: string; }'.'
const x: TestMap = {
[Test.A]: 'string',
[Test.B]: 'another string'
}
Expected behavior:
Keys from a string enum to be usable as static key names, similar to how constant strings are usable in computed key position. This probably should work even with non-const
enums.
const x: TestMap = { // currently works
['a']: 'string',
['b']: 'another string'
}
Actual behavior:
Not usable without a (potentially incorrect?) type assertion.