jkchao / typescript-book-chinese

TypeScript Deep Dive 中文版
https://jkchao.github.io/typescript-book-chinese/
MIT License
6.53k stars 673 forks source link

docs: 修正错误 #262

Closed sjxg closed 2 years ago

sjxg commented 2 years ago

如果不修改,则 type Param 代码的运行结果不正确,因为 infer P 指代的是参数数组 [User]:

type ParamType<T> = T extends (...args: infer P) => any ? P : T;
type Func = (user: User) => void;

type Param = ParamType<Func>; // type Param = [user: User] 而不是 type Param = User