Skip to content

Commit b5ac780

Browse files
committed
translated the rest
1 parent 6b9c142 commit b5ac780

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

docs/documentation/ko/handbook-v2/Everyday Types.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -576,24 +576,24 @@ configure("automatic");
576576
불 리터럴에는 오직 두 개의 타입만이 존재하며, 이는 익히 예상하셨듯이 `true``false`입니다.
577577
`boolean` 타입 자체는 사실 단지 `true | false` 유니언 타입의 별칭입니다.
578578

579-
### Literal Inference
579+
### 리터럴 추론
580580

581-
When you initialize a variable with an object, TypeScript assumes that the properties of that object might change values later.
582-
For example, if you wrote code like this:
581+
객체를 사용하여 변수를 초기화하면, TypeScript는 해당 객체의 프로퍼티는 이후에 그 값이 변화할 수 있다고 가정합니다.
582+
예를 들어, 아래와 같은 코드를 작성하는 경우를 보겠습니다.
583583

584584
```ts twoslash
585585
declare const someCondition: boolean;
586-
// ---cut---
586+
// ---중간 생략---
587587
const obj = { counter: 0 };
588588
if (someCondition) {
589589
obj.counter = 1;
590590
}
591591
```
592592

593-
TypeScript doesn't assume the assignment of `1` to a field which previously had `0` is an error.
594-
Another way of saying this is that `obj.counter` must have the type `number`, not `0`, because types are used to determine both _reading_ and _writing_ behavior.
593+
기존에 값이 `0`이었던 필드에 `1`을 대입하였을 때 TypeScript는 이를 오류로 간주하지 않습니다.
594+
이를 달리 말하면 `obj.counter`는 반드시 `number` 타입을 가져야 하며, `0` 리터럴 타입을 가질 수 없다는 의미입니다. 왜냐하면 타입은 _읽기__쓰기_ 두 동작을 결정하는 데에 사용되기 때문입니다.
595595

596-
The same applies to strings:
596+
동일한 사항이 문자열에도 적용됩니다.
597597

598598
```ts twoslash
599599
// @errors: 2345
@@ -603,113 +603,113 @@ const req = { url: "https://example.com", method: "GET" };
603603
handleRequest(req.url, req.method);
604604
```
605605

606-
In the above example `req.method` is inferred to be `string`, not `"GET"`. Because code can be evaluated between the creation of `req` and the call of `handleRequest` which could assign a new string like `"GUESS"` to `req.method`, TypeScript considers this code to have an error.
606+
위 예시에서 `req.method``string`으로 추론되지, `"GET"`으로 추론되지 않습니다. `req`의 생성 시점과 `handleRequest`의 호출 시점 사이에도 얼마든지 코드 평가가 발생할 수 있고, 이때 `req.method``"GUESS"`와 같은 새로운 문자열이 대입될 수도 있으므로, TypeScript는 위 코드에 오류가 있다고 판단합니다.
607607

608-
There are two ways to work around this.
608+
이러한 경우를 해결하는 데에는 두 가지 방법이 있습니다.
609609

610-
1. You can change the inference by adding a type assertion in either location:
610+
1. 둘 중에 한 위치에 타입 단언을 추가하여 추론 방식을 변경할 수 있습니다.
611611

612612
```ts twoslash
613613
declare function handleRequest(url: string, method: "GET" | "POST"): void;
614614
// ---cut---
615-
// Change 1:
615+
// 수정 1:
616616
const req = { url: "https://example.com", method: "GET" as "GET" };
617-
// Change 2
617+
// 수정 2
618618
handleRequest(req.url, req.method as "GET");
619619
```
620620

621-
Change 1 means "I intend for `req.method` to always have the _literal type_ `"GET"`", preventing the possible assignment of `"GUESS"` to that field after.
622-
Change 2 means "I know for other reasons that `req.method` has the value `"GET"`".
621+
수정 1은 "`req.method`가 항상 _리터럴 타입_ `"GET"`이기를 의도하며, 이에 따라 해당 필드에 `"GUESS"`와 같은 값이 대입되는 경우를 미연에 방지하겠다"는 것을 의미합니다.
622+
수정 2는 "무슨 이유인지, `req.method``"GET"`을 값으로 가진다는 사실을 알고 있다"는 것을 의미합니다.
623623

624-
2. You can use `as const` to convert the entire object to be type literals:
624+
2. `as const`를 사용하여 객체 전체를 리터럴 타입으로 변환할 수 있습니다.
625625

626626
```ts twoslash
627627
declare function handleRequest(url: string, method: "GET" | "POST"): void;
628-
// ---cut---
628+
// ---중간 생략---
629629
const req = { url: "https://example.com", method: "GET" } as const;
630630
handleRequest(req.url, req.method);
631631
```
632632

633-
The `as const` suffix acts like `const` but for the type system, ensuring that all properties are assigned the literal type instead of a more general version like `string` or `number`.
633+
`as const` 접미사는 일반적인 `const`와 유사하게 작동하는데, 해당 객체의 모든 프로퍼티에 `string` 또는 `number`와 같은 보다 일반적인 타입이 아닌 리터럴 타입의 값이 대입되도록 보장합니다.
634634

635-
## `null` and `undefined`
635+
## `null` `undefined`
636636

637-
JavaScript has two primitive values used to signal absent or uninitialized value: `null` and `undefined`.
637+
JavaScript에는 빈 값 또는 초기화되지 않은 값을 가리키는 두 가지 원시값이 존재합니다. 바로 `null``undefined`입니다.
638638

639-
TypeScript has two corresponding _types_ by the same names. How these types behave depends on whether you have the `strictNullChecks` option on.
639+
TypeScript에는 각 값에 대응하는 동일한 이름의 두 가지 _타입_이 존재합니다. 각 타입의 동작 방식은 `strictNullChecks` 옵션의 설정 여부에 따라 달라집니다.
640640

641-
### `strictNullChecks` off
641+
### `strictNullChecks`가 설정되지 않았을 때
642642

643-
With `strictNullChecks` _off_, values that might be `null` or `undefined` can still be accessed normally, and the values `null` and `undefined` can be assigned to a property of any type.
644-
This is similar to how languages without null checks (e.g. C#, Java) behave.
645-
The lack of checking for these values tends to be a major source of bugs; we always recommend people turn `strictNullChecks` on if it's practical to do so in their codebase.
643+
`strictNullChecks`_설정되지 않았다면_, 어떤 값이 `null` 또는 `undefined`일 수 있더라도 해당 값에 평소와 같이 접근할 수 있으며, `null``undefined`는 모든 타입의 변수에 대입될 수 있습니다.
644+
이는 Null 검사를 하지 않는 언어(C#, Java 등)의 동작 방식과 유사합니다.
645+
Null 검사의 부재는 버그의 주요 원인이 되기도 합니다. 별 다른 이유가 없다면, 코드 전반에 걸쳐 `strictNullChecks` 옵션을 설정하는 것을 항상 권장합니다.
646646

647-
### `strictNullChecks` on
647+
### `strictNullChecks` 설정되었을 때
648648

649-
With `strictNullChecks` _on_, when a value is `null` or `undefined`, you will need to test for those values before using methods or properties on that value.
650-
Just like checking for `undefined` before using an optional property, we can use _narrowing_ to check for values that might be `null`:
649+
`strictNullChecks`_설정되었다면_, 어떤 값이 `null` 또는 `undefined`일 때, 해당 값과 함께 메서드 또는 프로퍼티를 사용하기에 앞서 해당 값을 테스트해야 합니다.
650+
옵셔널 프로퍼티를 사용하기 앞서 `undefined` 여부를 검사하는 것과 마찬가지로, _좁히기_를 통하여 `null`일 수 있는 값에 대한 검사를 수행할 수 있습니다.
651651

652652
```ts twoslash
653653
function doSomething(x: string | undefined) {
654654
if (x === undefined) {
655-
// do nothing
655+
// 아무 것도 하지 않는다
656656
} else {
657657
console.log("Hello, " + x.toUpperCase());
658658
}
659659
}
660660
```
661661

662-
### Non-null Assertion Operator (Postfix `!`)
662+
### Null 아님 단언 연산자 (접두사 `!`)
663663

664-
TypeScript also has a special syntax for removing `null` and `undefined` from a type without doing any explicit checking.
665-
Writing `!` after any expression is effectively a type assertion that the value isn't `null` or `undefined`:
664+
TypeScript에서는 명시적인 검사를 하지 않고도 타입에서 `null``undefined`를 제거할 수 있는 특별한 구문을 제공합니다.
665+
표현식 뒤에 `!`를 작성하면 해당 값이 `null` 또는 `undefined`가 아니라고 타입 단언하는 것입니다.
666666

667667
```ts twoslash
668668
function liveDangerously(x?: number | undefined) {
669-
// No error
669+
// 오류 없음
670670
console.log(x!.toFixed());
671671
}
672672
```
673673

674-
Just like other type assertions, this doesn't change the runtime behavior of your code, so it's important to only use `!` when you know that the value _can't_ be `null` or `undefined`.
674+
다른 타입 단언과 마찬가지로 이 구문은 코드의 런타임 동작을 변화시키지 않으므로, `!` 연산자는 반드시 해당 값이 `null` 또는 `undefined`_아닌_ 경우에만 사용해야 합니다.
675675

676-
### Enums
676+
### 열거형
677677

678-
Enums are a feature added to JavaScript by TypeScript which allows for describing a value which could be one of a set of possible named constants. Unlike most TypeScript features, this is _not_ a type-level addition to JavaScript but something added to the language and runtime. Because of this, it's a feature which you should know exists, but maybe hold off on using unless you are sure. You can read more about enums in the [Enum reference page](/docs/handbook/enums.html).
678+
열거형은 TypeScript가 JavaScript에 추가하는 기능으로, 어떤 값이 _이름이 있는 상수 집합_에 속한 값 중 하나일 수 있도록 제한하는 기능입니다. 대부분의 TypeScript 기능과 달리, 이 기능은 JavaScript에 타입 수준이 _아닌_, 언어와 런타임 수준에 추가되는 기능입니다. 따라서 열거형이 무엇인지는 알 필요가 있겠으나, 그 사용법을 명확하게 파악하지 않았다면 실제 사용은 보류하는 것이 좋습니다. 열거형에 대한 자세한 내용을 확인하려면 [열거형 문서](https://www.typescriptlang.org/ko/docs/handbook/enums.html)를 읽어보시기 바랍니다.
679679

680-
### Less Common Primitives
680+
### 자주 사용되지 않는 원시형 타입
681681

682-
It's worth mentioning the rest of the primitives in JavaScript which are represented in the type system.
683-
Though we will not go into depth here.
682+
앞서 언급한 타입 이외에, 타입 시스템에 존재하는 나머지 JavaScript 원시 타입들을 다루도록 하겠습니다.
683+
물론, 여기서 깊게 다루지는 않을 것입니다.
684684

685685
##### `bigint`
686686

687-
From ES2020 onwards, there is a primitive in JavaScript used for very large integers, `BigInt`:
687+
ES2020 이후, 아주 큰 정수를 다루기 위한 원시 타입이 JavaScript에 추가되었습니다. 바로 `bigint`입니다.
688688

689689
```ts twoslash
690690
// @target: es2020
691691

692-
// Creating a bigint via the BigInt function
692+
// BigInt 함수를 통하여 bigint 값을 생성
693693
const oneHundred: bigint = BigInt(100);
694694

695-
// Creating a BigInt via the literal syntax
695+
// 리터럴 구문을 통하여 bigint 값을 생성
696696
const anotherHundred: bigint = 100n;
697697
```
698698

699-
You can learn more about BigInt in [the TypeScript 3.2 release notes](/docs/handbook/release-notes/typescript-3-2.html#bigint).
699+
BigInt에 대한 더 자세한 내용은 [TypeScript 3.2 릴리즈 노트]((/docs/handbook/release-notes/typescript-3-2.html#bigint))에서 확인할 수 있습니다.
700700

701701
##### `symbol`
702702

703-
There is a primitive in JavaScript used to create a globally unique reference via the function `Symbol()`:
703+
`symbol`은 전역적으로 고유한 참조값을 생성하는 데에 사용할 수 있는 원시 타입이며, `Symbol()` 함수를 통하여 생성할 수 있습니다.
704704

705705
```ts twoslash
706706
// @errors: 2367
707707
const firstName = Symbol("name");
708708
const secondName = Symbol("name");
709709

710710
if (firstName === secondName) {
711-
// Can't ever happen
711+
// 절대로 일어날 수 없습니다
712712
}
713713
```
714714

715-
You can learn more about them in [Symbols reference page](/docs/handbook/symbols.html).
715+
Symbol에 대한 더 자세한 내용은 [심벌 문서](https://www.typescriptlang.org/ko/docs/handbook/symbols.html)에서 확인할 수 있습니다.

0 commit comments

Comments
 (0)