2021年3月18日星期四

Typescript subset of enum

In Typescript, I have an enum like

export enum CarBrands {     Toyota = "TOYOTA"     Ford = "FORD"     .....  }  

I would like to create a subset of this enum like this but cannot seem to do it

enum JapaneseCars {      CarBrands.Toyota  }  

or create an object with a subset

const JapaneseCars = {      Carbrands.Toyota  }  

Is there anyway i can create an object or enum that uses that values from another existing enum?

I cannot change the CarBrands enum to be some other data type

https://stackoverflow.com/questions/66702281/typescript-subset-of-enum March 19, 2021 at 11:52AM

没有评论:

发表评论