how should implement typescript interface define c# models:
public class pagemodel { public long id { get; set; } public string name { get; set; } public idictionary<string, fieldmodel> fields { get; set; } } public class fieldmodel { public long id { get; set; } public string name { get; set; } public string type { get; set; } public string datatype { get; set; } public string defaultvalue { get; set; } }
if you're looking interfaces then:
interface pagemodel { id: number; name: string; fields: { [key: string]: fieldmodel }; } interface fieldmodel { id: number; name: string; type: string; datatype: string; defaultvalue: string; }
some differences:
- javascript has no notion of long/integer/double, numbers
- in simple map implementation based on js object notation, keys strings. in typescript these called indexable types
- while use get/set inside classes, interfaces don't have , can define property.
Comments
Post a Comment