I don't understand this code:
export interface MyType {
[propertyName: string]: string | MyType;
}
I understand that types in a global way serve a function to generalize its use with the business objects of our applications. Types allow to capture the type the user provides in the function.
But in the above code I don't understand:
- the usefulness of the syntax with brackets for the property;
- the fact that the interface has a property whose value is the interface itself. Are interfaces recursive?
It is typescript not angular first
And I think this is better use key
in your example [] is used for key that can be string only. It can't be
Key should be string only like
Answer The fact that the interface has a property whose value is the interface itself. Are the interfaces recursives
Yes they are