11---
22title : Typeof Type Operator
33layout : docs
4- permalink : /docs/handbook/2/typeof-types.html
5- oneline : " Using the typeof operator in type contexts ."
4+ permalink : /ko/ docs/handbook/2/typeof-types.html
5+ oneline : " 타입 컨텍스트에서 typeof 연산자 사용하기 ."
66---
77
8- ## The ` typeof ` type operator
8+ ## ` typeof ` 타입 연산자
99
10- JavaScript already has a ` typeof ` operator you can use in an _ expression _ context:
10+ JavaScript에서는 이미 _ 표현식 _ 컨텍스트에서 사용할 수 있는 ` typeof ` 연산자가 있습니다.
1111
1212``` ts twoslash
13- // Prints "string"
13+ // "string"을 출력합니다
1414console .log (typeof " Hello world" );
1515```
1616
17- TypeScript adds a ` typeof ` operator you can use in a _ type _ context to refer to the _ type _ of a variable or property:
17+ TypeScript는 _ 타입 _ 컨텍스트에서 변수나 프로퍼티의 타입을 추론할 수 있는 ` typeof ` 연산자를 추가합니다.
1818
1919``` ts twoslash
2020let s = " hello" ;
2121let n: typeof s ;
2222// ^?
2323```
2424
25- This isn't very useful for basic types, but combined with other type operators, you can use ` typeof ` to conveniently express many patterns .
26- For an example, let's start by looking at the predefined type ` ReturnType<T> ` .
27- It takes a _ function type _ and produces its return type:
25+ 기본 타입에 대해선 별로 유용하진 않지만, 다른 타입 연산자와 함께 ` typeof ` 를 사용하여 많은 패턴을 편리하게 표현할 수 있습니다 .
26+ 예를 들어, 미리 정의된 타입인 ` ReturnType<T> ` 부터 살펴보겠습니다 .
27+ 위 타입은 _ 함수 타입 _ 을 받으면서 반환되는 타입을 제공합니다.
2828
2929``` ts twoslash
3030type Predicate = (x : unknown ) => boolean ;
3131type K = ReturnType <Predicate >;
3232// ^?
3333```
3434
35- If we try to use ` ReturnType ` on a function name, we see an instructive error:
35+ 함수 이름에 ` ReturnType ` 을 사용하면, 안내 오류를 확인할 수 있습니다.
3636
3737``` ts twoslash
3838// @errors: 2749
@@ -42,8 +42,8 @@ function f() {
4242type P = ReturnType <f >;
4343```
4444
45- Remember that _ values _ and _ types _ aren't the same thing .
46- To refer to the _ type _ that the _ value ` f ` _ has, we use ` typeof ` :
45+ _ 값 _ 과 _ 타입 _ 은 같지 않다는 것을 명심하세요 .
46+ _ 값 ` f ` _ 의 _ 타입 _ 을 추론하기 위해서 ` typeof ` 를 사용합니다.
4747
4848``` ts twoslash
4949function f() {
@@ -53,12 +53,12 @@ type P = ReturnType<typeof f>;
5353// ^?
5454```
5555
56- ### Limitations
56+ ### 제한
5757
58- TypeScript intentionally limits the sorts of expressions you can use ` typeof ` on .
58+ TypeScript는 ` typeof ` 를 사용할 수 있는 표현식의 종류를 의도적으로 제한합니다 .
5959
60- Specifically, it's only legal to use ` typeof ` on identifiers (i.e. variable names) or their properties .
61- This helps avoid the confusing trap of writing code you think is executing, but isn't:
60+ 특히, 식별자(예: 변수이름) 혹은 프로퍼티에서만 ` typeof ` 를 사용할 수 있습니다 .
61+ 실행 중인 것으로 생각되는 코드 작성의 실수를 피하는데 도움을 줄 수 있지만, 그렇진 않습니다.
6262
6363``` ts twoslash
6464// @errors: 1005
0 commit comments