Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

451
Views
Is it possible to have nested enum in Typescript?

Having those enums:

export enum First {
  TEST_1 = 'test_1',
  TEST_2 = 'test_2'
}

export enum Second {
  TEST_3 = 'test_3',
  TEST_4 = 'test_4'
}

is it possible to combine them into a single one?

Something like:

export enum Main {
  First {
    TEST_1 = 'test_1',
    TEST_2 = 'test_2'
  },
  Second {
    TEST_3 = 'test_3',
    TEST_4 = 'test_4'
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can’t create nested enums in TypeScript. What you could do is create a little hack where you can create an object (Main), which contains a bunch of enums and essentially achieve the same effect

enum First {
    TEST_1 = "Main.First.Test1",
    TEST_2 = "Main.First.Test2"
}

enum Second {
    TEST_3 = "Main.Second.Test3",
    TEST_4 = "Main.Second.Test4"
}

const Main = {
    First,
    Second
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!