Skip to content

Commit 6d6c10e

Browse files
Merge pull request #188 from jaryapp/ts-4.9-ko-satisfies
Co-authored-by: bumkeyy <bumkeyy@users.noreply.github.com>
2 parents 5c6b886 + 9cdbe62 commit 6d6c10e

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

β€Ždocs/documentation/ko/release-notes/TypeScript 4.9.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ permalink: /ko/docs/handbook/release-notes/typescript-4-9.html
55
oneline: TypeScript 4.9 릴리즈 λ…ΈνŠΈ
66
---
77

8-
## The `satisfies` Operator
8+
## `satisfies` μ—°μ‚°μž
99

10-
TypeScript developers are often faced with a dilemma: we want to ensure that some expression *matches* some type, but also want to keep the *most specific* type of that expression for inference purposes.
10+
TypeScript κ°œλ°œμžλ“€μ€ μ’…μ’… λ”œλ ˆλ§ˆμ— μ§λ©΄ν•©λ‹ˆλ‹€. μš°λ¦¬λŠ” 일뢀 ν‘œν˜„μ‹μ΄ νƒ€μž…κ³Ό *일치*ν•˜λŠ”μ§€ ν™•μΈν•˜κ³  μ‹Άμ§€λ§Œ, 좔둠을 μœ„ν•΄ ν‘œν˜„μ‹μ˜ *κ°€μž₯ ꡬ체적인 νƒ€μž…*을 μœ μ§€ν•˜κ³  싢을 λ•Œκ°€ μžˆμŠ΅λ‹ˆλ‹€.
1111

12-
For example:
12+
예λ₯Ό λ“€μ–΄
1313

1414
```ts
15-
// Each property can be a string or an RGB tuple.
15+
// 각 속성은 λ¬Έμžμ—΄ λ˜λŠ” RGB νŠœν”ŒμΌ 수 μžˆμŠ΅λ‹ˆλ‹€.
1616
const palette = {
1717
red: [255, 0, 0],
1818
green: "#00ff00",
1919
bleu: [0, 0, 255]
20-
// ^^^^ sacrebleu - we've made a typo!
20+
// ^^^^ sacrebleu - μ˜€νƒ€λ₯Ό λƒˆμŠ΅λ‹ˆλ‹€!
2121
};
2222

23-
// We want to be able to use array methods on 'red'...
23+
// μš°λ¦¬λŠ” λ°°μ—΄ λ©”μ„œλ“œλ₯Ό 'red'에 μ‚¬μš©ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€...
2424
const redComponent = palette.red.at(0);
2525

26-
// or string methods on 'green'...
26+
// ν˜Ήμ€ 'green'에 λ¬Έμžμ—΄ λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜κ³  싢을 수 μžˆμŠ΅λ‹ˆλ‹€...
2727
const greenNormalized = palette.green.toUpperCase();
2828
```
2929

30-
Notice that we've written `bleu`, whereas we probably should have written `blue`.
31-
We could try to catch that `bleu` typo by using a type annotation on `palette`, but we'd lose the information about each property.
30+
μš°λ¦¬λŠ” `bleu` λŒ€μ‹ , `blue`λ₯Ό 썼어야 ν–ˆμŠ΅λ‹ˆλ‹€.
31+
`palette`에 νƒ€μž…μ„ ν‘œκΈ°ν•΄μ„œ `bleu` μ˜€νƒ€λ₯Ό μž‘μ„ μˆ˜λ„ μžˆμ§€λ§Œ, κ·Έλ ‡κ²Œ 되면 각 속성에 λŒ€ν•œ 정보λ₯Ό μžƒκ²Œ λ©λ‹ˆλ‹€.
3232

3333
```ts
3434
type Colors = "red" | "green" | "blue";
@@ -39,15 +39,15 @@ const palette: Record<Colors, string | RGB> = {
3939
red: [255, 0, 0],
4040
green: "#00ff00",
4141
bleu: [0, 0, 255]
42-
// ~~~~ The typo is now correctly detected
42+
// ~~~~ 이제 μ˜€νƒ€λ₯Ό μ˜¬λ°”λ₯΄κ²Œ κ°μ§€ν–ˆμŠ΅λ‹ˆλ‹€.
4343
};
4444

45-
// But we now have an undesirable error here - 'palette.red' "could" be a string.
45+
// ν•˜μ§€λ§Œ μ—¬κΈ°μ„œ μ›μΉ˜ μ•ŠλŠ” λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. 'palette.red'κ°€ λ¬Έμžμ—΄μ΄ "될 수 μžˆλ‹€"λŠ”κ²ƒ μž…λ‹ˆλ‹€.
4646
const redComponent = palette.red.at(0);
4747
```
4848

49-
The new `satisfies` operator lets us validate that the type of an expression matches some type, without changing the resulting type of that expression.
50-
As an example, we could use `satisfies` to validate that all the properties of `palette` are compatible with `string | number[]`:
49+
`satisfies` μ—°μ‚°μžλ₯Ό μ‚¬μš©ν•˜λ©΄ ν‘œν˜„μ‹μ˜ κ²°κ³Ό νƒ€μž…μ„ λ³€κ²½ν•˜μ§€ μ•Šκ³  ν‘œν˜„μ‹μ˜ νƒ€μž…μ΄ νŠΉμ • νƒ€μž…κ³Ό μΌμΉ˜ν•˜λŠ”μ§€ 검증할 수 μžˆμŠ΅λ‹ˆλ‹€.
50+
예λ₯Ό λ“€μ–΄, μš°λ¦¬λŠ” `satisfies`λ₯Ό μ‚¬μš©ν•˜μ—¬ `palette`의 λͺ¨λ“  속성이 `string | number[]`와 ν˜Έν™˜λ˜λŠ”μ§€ 검증할 수 μžˆμŠ΅λ‹ˆλ‹€.
5151

5252
```ts
5353
type Colors = "red" | "green" | "blue";
@@ -58,35 +58,35 @@ const palette = {
5858
red: [255, 0, 0],
5959
green: "#00ff00",
6060
bleu: [0, 0, 255]
61-
// ~~~~ The typo is now caught!
61+
// ~~~~ μ˜€νƒ€κ°€ μž‘ν˜”μŠ΅λ‹ˆλ‹€!
6262
} satisfies Record<Colors, string | RGB>;
6363

64-
// Both of these methods are still accessible!
64+
// 두 λ©”μ„œλ“œ λͺ¨λ‘ μ—¬μ „νžˆ μ ‘κ·Όν•  수 μžˆμŠ΅λ‹ˆλ‹€!
6565
const redComponent = palette.red.at(0);
6666
const greenNormalized = palette.green.toUpperCase();
6767
```
6868

69-
`satisfies` can be used to catch lots of possible errors.
70-
For example, we could ensure that an object has *all* the keys of some type, but no more:
69+
`satisfies`λŠ” λ§Žμ€ 였λ₯˜λ₯Ό νƒμ§€ν•˜λŠ”λ° μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
70+
예λ₯Ό λ“€λ©΄, 객체가 νŠΉμ • νƒ€μž…μ˜ *λͺ¨λ“ * ν‚€λ₯Ό κ°€μ§€μ§€λ§Œ, κ·Έ 이상은 κ°€μ§€μ§€ μ•Šλ„λ‘ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
7171

7272
```ts
7373
type Colors = "red" | "green" | "blue";
7474

75-
// Ensure that we have exactly the keys from 'Colors'.
75+
// 'Colors' ν‚€κ°€ μ •ν™•ν•œμ§€ ν™•μΈν•©λ‹ˆλ‹€.
7676
const favoriteColors = {
7777
"red": "yes",
7878
"green": false,
7979
"blue": "kinda",
8080
"platypus": false
81-
// ~~~~~~~~~~ error - "platypus" was never listed in 'Colors'.
81+
// ~~~~~~~~~~ μ—λŸ¬ - "platypus"λŠ” 'Colors' λ¦¬μŠ€νŠΈμ— μ—†μŠ΅λ‹ˆλ‹€.
8282
} satisfies Record<Colors, unknown>;
8383

84-
// All the information about the 'red', 'green', and 'blue' properties are retained.
84+
// 'red', 'green' 및 'blue' μ†μ„±μ˜ λͺ¨λ“  정보가 μœ μ§€λ©λ‹ˆλ‹€.
8585
const g: boolean = favoriteColors.green;
8686
```
8787

88-
Maybe we don't care about if the property names match up somehow, but we do care about the types of each property.
89-
In that case, we can also ensure that all of an object's property values conform to some type.
88+
μ΄λ”°κΈˆ μš°λ¦¬λŠ” 속성 이름 일치 여뢀보닀 각 μ†μ„±μ˜ νƒ€μž…μ— 관심이 μžˆμ„ 수 μžˆμŠ΅λ‹ˆλ‹€.
89+
이 경우 개체의 λͺ¨λ“  속성 값이 일뢀 νƒ€μž…μ„ μ€€μˆ˜ν•˜λŠ”μ§€ 확인할 μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.
9090

9191
```ts
9292
type RGB = [red: number, green: number, blue: number];
@@ -95,16 +95,16 @@ const palette = {
9595
red: [255, 0, 0],
9696
green: "#00ff00",
9797
blue: [0, 0]
98-
// ~~~~~~ error!
98+
// ~~~~~~ μ—λŸ¬!
9999
} satisfies Record<string, string | RGB>;
100100

101-
// Information about each property is still maintained.
101+
// 각 속성에 λŒ€ν•œ μ •λ³΄λŠ” 계속 μœ μ§€λ©λ‹ˆλ‹€.
102102
const redComponent = palette.red.at(0);
103103
const greenNormalized = palette.green.toUpperCase();
104104
```
105105

106-
For more examples, you can see the [issue proposing this](https://github.com/microsoft/TypeScript/issues/47920) and [the implementing pull request](https://github.com/microsoft/TypeScript/pull/46827).
107-
We'd like to thank [Oleksandr Tarasiuk](https://github.com/a-tarasyuk) who implemented and iterated on this feature with us.
106+
더 λ§Žμ€ μ˜ˆμ‹œλ₯Ό 보고 μ‹Άλ‹€λ©΄, [μ œμ•ˆν•œ 이슈](https://github.com/microsoft/TypeScript/issues/47920) 와 [이λ₯Ό κ΅¬ν˜„ν•œ pull request](https://github.com/microsoft/TypeScript/pull/46827)λ₯Ό ν™•μΈν•˜μ„Έμš”.
107+
μš°λ¦¬μ™€ ν•¨κ»˜ 이 κΈ°λŠ₯을 κ΅¬ν˜„ν•œ [Oleksandr Tarasiuk](https://github.com/a-tarasyuk)μ—κ²Œ κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.
108108

109109
## Unlisted Property Narrowing with the `in` Operator
110110

0 commit comments

Comments
Β (0)