Enum

enum TestType {
  A = "a"
}

export default TestType;
declare interface Test{
    type: import("../enums/TestType).default
}
  • Actually, enum is a javascript object

enum ChannelType {
  API_KEY ,
  PLAYGROUND,
  TEAMS
}

enum ChannelType2 {
  API_KEY = "api_key" ,
  PLAYGROUND = "playground",
  TEAMS = "teams"
}
console.log(ChannelType, ChannelType2);

/*
Results: 
  // ChannelType
  {
    "0": "API_KEY",
    "1": "PLAYGROUND",
    "2": "TEAMS",
    "API_KEY": 0,
    "PLAYGROUND": 1,
    "TEAMS": 2
  }
   
  // ChannelType2
  {
    "API_KEY": "api_key",
    "PLAYGROUND": "playground",
    "TEAMS": "teams"
  } 
*/

Last updated

Was this helpful?