-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
preserveConstEnums = true
const enum EnumCacheName
{
'toc_contents' = '.toc_contents.cache'
}
let { target } = yargs
.option('target', {
type: 'string',
})
.argv
;
let cache_file = path.join(ProjectConfig.cache_root, EnumCacheName[target as any]);Expected behavior:
no error, because this code exists in .js
var EnumCacheName;
(function (EnumCacheName) {
EnumCacheName["toc_contents"] = ".toc_contents.cache";
})(EnumCacheName || (EnumCacheName = {}));Actual behavior:
Error: TS2476: A const enum member can only be accessed using a string literal.
Playground Link:
Related Issues:
akdcl, fmatzy, Harpush, dahjelle, SPGoding and 4 more
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript