[TypeScript] TypeScript对象转JSON字符串范例 Playground http://tinyurl.com/njbrnrv Samples class DataTable { public columns: Array<string> = new Array<string>(); public rows: Array<DataRow> = new Array<DataRow>(); } class DataRow { public c…
Handling state with Typescript enums, instead of booleans, is preferred because:- Enums are more readable- Enums can have as many states as you need while booleans only have 2- You only need to keep track of state with 1 variable when using enums Typ…
TypeScript has 'interface' and 'type', so when to use which? interface hasName { firstName: string; lastName: string; } interface hasAddress { address: string } type Player = (hasName & hasAddress) | null; let player: Player = {firstName: 'Joe', last…