-
Notifications
You must be signed in to change notification settings - Fork 0
TypeScript : T in Function
ythy edited this page Dec 27, 2017
·
1 revision
函数类的泛型,取决于函数的传值或者返回值。泛型特性都标注在函数泛型上
例1:
function createFactory<T extends HTMLElement>(
type: keyof ReactHTML): HTMLFactory<T>;
返回值类型T,决定了函数的泛型.
例2:
function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
type: ClassType<P, T, C>): CFactory<P, T>;
函数的参数和返回值 P T C共同决定了函数的泛型
tell me how get back to sunshine