Skip to content

Commit 2c8bba7

Browse files
authored
intersection type: first commit (#170)
1 parent fc4defa commit 2c8bba7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

β€Žpages/unions-and-intersections.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,15 @@ function networkStatus(state: NetworkState): string {
223223
}
224224
```
225225

226-
# Intersection Types
226+
# ꡐ차 νƒ€μž… (Intersection Types)
227227

228-
Intersection types are closely related to union types, but they are used very differently.
229-
An intersection type combines multiple types into one.
230-
This allows you to add together existing types to get a single type that has all the features you need.
231-
For example, `Person & Serializable & Loggable` is a type which is all of `Person` _and_ `Serializable` _and_ `Loggable`.
232-
That means an object of this type will have all members of all three types.
228+
ꡐ차 νƒ€μž…μ€ μœ λ‹ˆμ–Έ νƒ€μž…κ³Ό λ°€μ ‘ν•œ 관련이 μžˆμ§€λ§Œ, μ‚¬μš© 방법은 맀우 λ‹€λ¦…λ‹ˆλ‹€.
229+
ꡐ차 νƒ€μž…μ€ μ—¬λŸ¬ νƒ€μž…μ„ ν•˜λ‚˜λ‘œ κ²°ν•©ν•©λ‹ˆλ‹€.
230+
κΈ°μ‘΄ νƒ€μž…μ„ 합쳐 ν•„μš”ν•œ κΈ°λŠ₯을 λͺ¨λ‘ κ°€μ§„ 단일 νƒ€μž…μ„ 얻을 수 μžˆμŠ΅λ‹ˆλ‹€.
231+
예λ₯Ό λ“€μ–΄, `Person & Serializable & Loggable`은 `Person` _κ³Ό_ `Serializable` _그리고_ `Loggable`μž…λ‹ˆλ‹€.
232+
즉, 이 νƒ€μž…μ˜ κ°μ²΄λŠ” μ„Έ κ°€μ§€ νƒ€μž…μ˜ λͺ¨λ“  멀버λ₯Ό κ°–κ²Œ λ©λ‹ˆλ‹€.
233233

234-
For example, if you had networking requests with consistent error handling then you could separate out the error handling into it's own type which is merged with types which correspond to a single response type.
234+
예λ₯Ό λ“€μ–΄, μΌκ΄€λœ μ—λŸ¬λ₯Ό λ‹€λ£¨λŠ” μ—¬λŸ¬ λ„€νŠΈμ›Œν¬ μš”μ²­μ΄ μžˆλ‹€λ©΄ ν•΄λ‹Ή μ—λŸ¬ 핸듀링을 λΆ„λ¦¬ν•˜μ—¬ ν•˜λ‚˜μ˜ 응닡 νƒ€μž…μ— λŒ€μ‘ν•˜λŠ” κ²°ν•©λœ 자체 νƒ€μž…μœΌλ‘œ λ§Œλ“€ 수 μžˆμŠ΅λ‹ˆλ‹€.
235235

236236
```ts
237237
interface ErrorHandling {
@@ -247,8 +247,8 @@ interface ArtistsData {
247247
artists: { name: string }[];
248248
}
249249

250-
// These interfaces are composed to have
251-
// consistent error handling, and their own data.
250+
// 이 μΈν„°νŽ˜μ΄μŠ€λ“€μ€
251+
// ν•˜λ‚˜μ˜ μ—λŸ¬ 핸듀링과 자체 λ°μ΄ν„°λ‘œ κ΅¬μ„±λ©λ‹ˆλ‹€.
252252

253253
type ArtworksResponse = ArtworksData & ErrorHandling;
254254
type ArtistsResponse = ArtistsData & ErrorHandling;
@@ -263,9 +263,9 @@ const handleArtistsResponse = (response: ArtistsResponse) => {
263263
};
264264
```
265265

266-
## Mixins via Intersections
266+
## ꡐ차λ₯Ό ν†΅ν•œ 믹슀인 (Mixins via Intersections)
267267

268-
Intersections are used to implement the [mixin pattern](/docs/handbook/mixins.html):
268+
κ΅μ°¨λŠ” [믹슀인 νŒ¨ν„΄](/docs/handbook/mixins.html)을 μ‹€ν–‰ν•˜κΈ° μœ„ν•΄ μ‚¬μš©λ©λ‹ˆλ‹€.
269269

270270
```ts
271271
class Person {
@@ -282,7 +282,7 @@ class ConsoleLogger implements Loggable {
282282
}
283283
}
284284

285-
// Takes two objects and merges them together
285+
// 두 객체λ₯Ό λ°›μ•„ ν•˜λ‚˜λ‘œ ν•©μΉ©λ‹ˆλ‹€.
286286
function extend<First extends {}, Second extends {}>(
287287
first: First,
288288
second: Second

0 commit comments

Comments
Β (0)