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

400
Views
How to concat additional string with the typescript type definition object?

Let says I have a type as follows:

export enum configType {
  value = 'blah bala',
  value2 = 'blah bala',
  value3 = 'blah bala',
  value2 = 'blah bala',

}

Now I want to create a new type with above enum as follows:

export type analog = {
    [v + '_key' in configType]?: boolean;
}

Would this be possible?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do this with literal types the type utilities Record<Keys, Type> and Partial<Type>.

TS Playground

enum ConfigType {
  Value = 'Value',
  Value2 = 'Value2',
  Value3 = 'Value3',
  Value4 = 'Value4',
}

type Analog = Partial<Record<`${ConfigType}_key`, boolean>>;

/*

type Analog = {
  Value_key?: boolean;
  Value2_key?: boolean;
  Value3_key?: boolean;
  Value4_key?: boolean;
}

*/
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!