Skip to content

docs: to Discriminated Unions from Contextual typing #114 #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 5, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update pages/tutorials/ts-for-functional-programmers.md
Co-authored-by: Seohee Park <dvlprsh103@gmail.com>
  • Loading branch information
annkimm and dvlprsh authored Sep 5, 2020
commit 400f28df92eed8dd1123a8147c52b510a440bdc6
6 changes: 3 additions & 3 deletions pages/tutorials/ts-for-functional-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ declare function map<T, U>(f: (t: T) => U, ts: T[]): U[];
let sns = map((n) => n.toString(), [1, 2, 3]);
```

여기에 예시인 `n: number` 에서 또한, `T` 과 `U`는 호출 전이라서
여기에서, 이 예시의 `n: number`에서 또한, `T` 과 `U`는 호출 전에
추론되지 않았음에도 불구하고.
실제로 `[1,2,3]` 으로 `T=number`을 추론한 다음에,
`n => n.toString()`의 리턴 타입으로 `U=string`을 추론하며,
`sns` 가 `string[]` 타입을 가지도록 합니다.
`n => n.toString()`의 리턴 타입으로 `U=string`을 추론하여,
`sns`가 `string[]` 타입을 가지도록 합니다.

추론은 어떤 순서로든 동작하겠지만, intellisense은 왼쪽에서 오른쪽으로만
동작하고, 그래서 TypeScript는 먼저 배열과 함께 `map` 선언하는 것을
Expand Down