Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Use json file string to enum shows Type 'string' is not assignable to type 'number' as required for computed enum member values

$
0
0

I have a enum like this:

export enum AccountSettings {  accountManagement = "Account management",  managementOfRelatives = 'Management of relatives',}

Then I have a en.json file, I want to use them for my enum data

{"account_management": "Account management","management_of_relatives": "Management of relatives",}

Then use it get the error:

import en from './en.json';export enum AccountSettings {  accountManagement = en.account_management, // shows Type 'string' is not assignable to type 'number'  managementOfRelatives = 'Management of relatives',}

How do I use en.json data to enum ?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>