TypeScript Generics
https://www.typescriptlang.org/docs/handbook/generics.html
泛型 1
Generic Interface
type Log = <T>(value: T) => T;
interface Log {
<T>(value: T):T
}
// 等价的,使用时无需指定类型:
let log: Log = ...
type Log<T> = (value: T) => T;
interface Log<T> {
(value: T):T
}
// 等价的,使用时必须指定类型
let log: Log<number> = ...
泛型 2
Generic Class
https://ts.chibicode.com/generics
https://alligator.io/typescript/generics-in-typescript/
https://www.tutorialsteacher.com/typescript/typescript-generic-interface
https://www.tutorialsteacher.com/typescript/typescript-generic-class
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!