Within my interface, there is a member with a complex type structured like this:
export interface Activity {
id: string;
name: string;
segment: Segment;
}
export interface Segment {
id: string;
name: string;
}
Coming from a C# background where nested classes are common, I can't help but wonder if there's a way to improve the structure by embedding the segment within the activity. However, I am unsure of what this concept is called or how to implement it in TypeScript/Angular as I have not come across any examples that match my specific need.
Is it feasible to achieve nested types like this in TypeScript/Angular? If so, what potential disadvantages or challenges should be considered aside from the added complexity to the interfaces? And if using interfaces for this purpose isn't recommended, could classes or other types be a better alternative?
I've made an effort to research this topic and here are some links I explored:
- This post outlines a similar structure but lacks details on internal entities.
- This thread discusses a relevant structure but does not provide a solution.
- Despite its title, this post delves into a different topic unrelated to my query.
- This thread received unclear downvotes despite addressing nested interfaces.
- While this post touches on similar concerns, it lacks a direct answer to my specific issue.
- This discussion goes into intricate details, but I couldn't find a solution that aligns with my requirements.