Typescript interface – add new value dynamically or create the interface dynamically

Published

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;
}

Source: Angular Material Quesions

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq