11---
22title : Indexed Access Types
33layout : docs
4- permalink : /docs/handbook/2/indexed-access-types.html
5- oneline : " Using Type['a'] syntax to access a subset of a type. "
4+ permalink : /ko/ docs/handbook/2/indexed-access-types.html
5+ oneline : " Type['a'] 구문을 사용해서 타입의 내부 요소에 접근하기 "
66---
77
8- We can use an _ indexed access type _ to look up a specific property on another type:
8+ 타입의 특정 프로퍼티를 찾기 위해서 _ 인덱싱된 접근 타입 _ 을 사용할 수 있습니다.
99
1010``` ts twoslash
1111type Person = { age: number ; name: string ; alive: boolean };
1212type Age = Person [" age" ];
1313// ^?
1414```
1515
16- The indexing type is itself a type, so we can use unions, ` keyof ` , or other types entirely:
16+ 인덱싱된 타입은 그 자체로도 타입이라서 유니언, ` keyof ` 혹은 타입 전체에 사용할 수 있습니다.
1717
1818``` ts twoslash
1919type Person = { age: number ; name: string ; alive: boolean };
@@ -29,7 +29,7 @@ type I3 = Person[AliveOrName];
2929// ^?
3030```
3131
32- You'll even see an error if you try to index a property that doesn't exist:
32+ 존재하지 않는 프로퍼티를 인덱싱하려고 하면 오류가 발생합니다.
3333
3434``` ts twoslash
3535// @errors: 2339
@@ -38,8 +38,8 @@ type Person = { age: number; name: string; alive: boolean };
3838type I1 = Person [" alve" ];
3939```
4040
41- Another example of indexing with an arbitrary type is using ` number ` to get the type of an array's elements .
42- We can combine this with ` typeof ` to conveniently capture the element type of an array literal:
41+ 또 다른 예로는 임의의 타입을 ` number ` 로 인덱싱해서 배열 요소의 타입을 가져올 수 있습니다 .
42+ ` typeof ` 와 결합하면 편리하게 배열 리터럴의 요소 타입을 캡쳐할 수 있습니다.
4343
4444``` ts twoslash
4545const MyArray = [
@@ -57,7 +57,8 @@ type Age2 = Person["age"];
5757// ^?
5858```
5959
60- You can only use types when indexing, meaning you can't use a ` const ` to make a variable reference:
60+ 인덱싱할 때 변수 참조를 위해 사용된 ` const ` 는 사용할 수 없고, 오로지 타입만 사용 가능합니다.
61+
6162
6263``` ts twoslash
6364// @errors: 2538 2749
@@ -67,7 +68,7 @@ const key = "age";
6768type Age = Person [key ];
6869```
6970
70- However, you can use a type alias for a similar style of refactor:
71+ 하지만, 비슷한 스타일의 리팩터로 타입 별칭을 사용할 수 있습니다.
7172
7273``` ts twoslash
7374type Person = { age: number ; name: string ; alive: boolean };
0 commit comments