Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Trojan0523 committed Jul 22, 2021
1 parent 13963fb commit b7b0409
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 前沿技术/58.精读《Typescript2.0 - 2.9》.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ declare function createStore(reducer: Reducer, enhancer: Enhancer);

可以清晰的看到,`createStore` 想表现的是对参数个数的重载,如果定义了函数类型重载,TS 会根据函数类型自动判断对应的是哪个定义。

而在 TS `2.3` 版本支持了泛型默认参数,**可以某些场景减少函数类型重载的代码量**,比如对于下面的代码:
而在 TS `2.3` 版本支持了泛型默认参数,**可以减少某些场景函数类型重载的代码量**,比如对于下面的代码:

```typescript
declare function create(): Container<HTMLDivElement, HTMLDivElement[]>;
Expand All @@ -300,7 +300,7 @@ declare function create<T extends HTMLElement, U extends HTMLElement>(
): Container<T, U[]>;
```

通过枚举表达了范型默认值,以及 U 与 T 之间可能存在的关系,这些都可以用泛型默认参数解决:
通过枚举表达了泛型默认值,以及 U 与 T 之间可能存在的关系,这些都可以用泛型默认参数解决:

```typescript
declare function create<T extends HTMLElement = HTMLDivElement, U = T[]>(
Expand Down

0 comments on commit b7b0409

Please sign in to comment.