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

178
Views
Typescript interface - add new value dynamically or create the interface dynamically

I have an Angular Material Table. Obviously, I have an interface from which is created the dataSource for the table. Is there any possibility to add a new value dynamically in the interface Or at least to create the interface dynamycally? Because the data which is coming from the backend it's unknown. Example: from this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
}

to this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  index: number;
}

or from this:

export interface PeriodicElement {}

to this:

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  index: number;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. It will be better to use it like,
export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
  [key: string]: string | number;
}

or just

export interface PeriodicElement {
  [key: string]: string | number;
}
  1. Otherwise you can create separate models and use union(|) operator.

  2. Also you can use Partials to achieve this.

  3. For creating dynamically Refer here

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!