摘要: function reverse(str: string): string; function reverse<T>(arr: T[]): T[]; function reverse<T>(stringOrArray: string | T[]): string | T[] { if (typeof 阅读全文
posted @ 2020-10-06 18:20 Zhentiw 阅读(155) 评论(0) 推荐(0)
摘要: class Pizza { constructor(private name: string, private price: number) {} } class List<T> { private list: T[]; addItem(item: T): void { this.list.push 阅读全文
posted @ 2020-10-06 18:14 Zhentiw 阅读(81) 评论(0) 推荐(0)
摘要: Discriminated (Tagged) Unions means that for two or more similar types, we have one common prop which can differentiate individual. interface Order { 阅读全文
posted @ 2020-10-06 15:27 Zhentiw 阅读(279) 评论(0) 推荐(0)
摘要: interface Order { id: string; amount: number; currency: string; } interface Stripe { card: string; cvc: string; } interface PayPal { email: string; } 阅读全文
posted @ 2020-10-06 15:18 Zhentiw 阅读(79) 评论(0) 推荐(0)