Skip to content

Commit

Permalink
Merge pull request ascoders#347 from feikerwu/patch-2
Browse files Browse the repository at this point in the history
typo: fix typo in 207.精读《Typescript infer 关键字》.md
  • Loading branch information
ascoders authored Aug 26, 2021
2 parents cd543b1 + 88560b6 commit 2c5f8ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 前沿技术/207.精读《Typescript infer 关键字》.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Typescript 官网也拿 `ReturnType` 这一经典例子说明它的作用:
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
```

理解为:如果 `T` 继承了 `extends (...args: any[]) => any` 类型,则返回类型 `R`,否则返回 `any`。其中 `R` 是什么呢?`R` 被定义在 `extends (...args: any[]) => infer R` 中,即 R 是从传入参数类型中推导出来的。
理解为:如果 `T` 继承了 `(...args: any[]) => any` 类型,则返回类型 `R`,否则返回 `any`。其中 `R` 是什么呢?`R` 被定义在 `extends (...args: any[]) => infer R` 中,即 R 是从传入参数类型中推导出来的。

## 精读

Expand Down

0 comments on commit 2c5f8ca

Please sign in to comment.