Repository navigation
Unable to use numeric enums as keys of a map #16842
Copy link
Copy link
Closed
Description
Activity
RyanCavanaugh commented
on Jun 29, 2017 MemberMore actionsWhat version did this work in? As far as I can tell this has never been legal
=== latest === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~ TS2322: Type 'Things' is not assignable to type 'string'. === 2.3 === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~ TS2322: Type 'Things' is not assignable to type 'string'. === 2.2 === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~ TS2322: Type 'Things' is not assignable to type 'string'. === 2.1 === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~ TS2322: Type 'Things' is not assignable to type 'string'. === 2.0 === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~~~~~~~~~~~ TS1170: A computed property name in a type literal must directly refer to a built-in symbol. clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~~~~~~~~~~~ TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~ TS2304: Cannot find name 'TKey'. === 1.8 === clipboard.ts:3 type ThingMap = {[TKey in Things]: boolean} ~~~~~~~~~~~~~~~~ TS1170: A computed property name in a type literal must directly refer to a built-in symbol.Ryan Cavanaugh (@RyanCavanaugh) doh, sorry! I misread #2491 (comment) (and the followup comment) as if it was supported
I think we can probably close this as a dupe of #13042
Ryan Cavanaugh (@RyanCavanaugh) but is it ever going to be supported/legal?
Amit Beckenstein (@amitbeck) it looks like it's on the roadmap: #13042 (comment)
Ian MacLeod (@nevir) I know, I've commented on that exact issue :) Didn't see the milestone change, thanks for reminding me.
- locked and limited conversation to collaborators
on Jun 14, 2018
Metadata
Metadata
Assignees
Labels
No labels
This appears to be a regression of #2491 (& #12425?)
TypeScript Version: 2.4.1
Code
Expected that this snippet does not produce errors, but it does:
[Playground]