Skip to content

Commit

Permalink
Merge pull request ascoders#412 from Trojan0523/patch-1
Browse files Browse the repository at this point in the history
fix: typo
  • Loading branch information
ascoders authored Apr 16, 2022
2 parents f5859db + 4485447 commit e043a91
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ f1("a", 42);
f1("b", "hello");
```
如果把参数定义为数组且使用或并列枚举时,其实就潜在包含了一个运行时的类型收窄。比如当第一个参数值为 `a` 时,第二个参数类型就确定为 `number`,第一个参数值为 `b` 时,第二个参数类型就确定为 `string`
如果把参数定义为元组且使用或并列枚举时,其实就潜在包含了一个运行时的类型收窄。比如当第一个参数值为 `a` 时,第二个参数类型就确定为 `number`,第一个参数值为 `b` 时,第二个参数类型就确定为 `string`
值得注意的是,这种类型推导是从前到后的,因为参数是自左向右传递的,所以是前面推导出后面,而不能是后面推导出前面(比如不能理解为,第二个参数为 `number` 类型,那第一个参数的值就必须为 `a`)。
Expand Down

0 comments on commit e043a91

Please sign in to comment.