Skip to content

Commit 342d78a

Browse files
Merge pull request #77 from yahma25/Translation-to-ko-playground-Built-in-Utility-Types
Translate 1 file to ko - Built in Utility Types
2 parents f27fa70 + 03daa19 commit 342d78a

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//// { order: 3, compiler: { strictNullChecks: true } }
2+
3+
// 대부분 코드에서 특정한 타입이 유용하다고 느낄 때,
4+
// TypeScript에 추가해서
5+
// 누구나 사용할 수 있게 하여
6+
// 가용성을 지속해서 의존할 수 있습니다
7+
8+
// Partial<Type>
9+
10+
// 타입을 갖고 모든 프로퍼티를
11+
// 선택적 프로퍼티로 변환하세요.
12+
13+
interface Sticker {
14+
id: number;
15+
name: string;
16+
createdAt: string;
17+
updatedAt: string;
18+
submitter: undefined | string;
19+
}
20+
21+
type StickerUpdateParam = Partial<Sticker>;
22+
23+
// Readonly<Type>
24+
25+
// 객체를 갖고 읽기 전용 프로퍼티를 만드세요.
26+
27+
type StickerFromAPI = Readonly<Sticker>;
28+
29+
// Record<KeysFrom, Type>
30+
31+
// KeysFrom의 프로퍼티 리스트를 사용하는 타입을 만들고
32+
// Type의 값을 전달하세요.
33+
34+
// 키로 사용할 리스트:
35+
type NavigationPages = "home" | "stickers" | "about" | "contact";
36+
37+
// 각각의 ^에 대한 데이터의 형태가 필요합니다:
38+
interface PageInfo {
39+
title: string;
40+
url: string;
41+
axTitle?: string;
42+
}
43+
44+
const navigationInfo: Record<NavigationPages, PageInfo> = {
45+
home: { title: "Home", url: "/" },
46+
about: { title: "About", url: "/about" },
47+
contact: { title: "Contact", url: "/contact" },
48+
stickers: { title: "Stickers", url: "/stickers/all" },
49+
};
50+
51+
// Pick<Type, Keys>
52+
53+
// Type에서 Keys 프로퍼티 집합을 선택하여 타입을 만드세요.
54+
// 기본적으로 타입에서
55+
// 타입 정보를 추출하기 위한 허용 목록입니다.
56+
57+
type StickerSortPreview = Pick<Sticker, "name" | "updatedAt">;
58+
59+
// Omit<Type, Keys>
60+
61+
// Type에서 Keys 프로퍼티 집합을 제거하여 타입을 만드세요.
62+
// 기본적으로 타입에서
63+
// 타입 정보를 추출하기 위한 차단 목록입니다.
64+
65+
type StickerTimeMetadata = Omit<Sticker, "name">;
66+
67+
// Exclude<Type, RemoveUnion>
68+
69+
// RemoveUnion과 겹치지 않는
70+
// Type 프로퍼티의 모든 프로퍼티 타입을 만드세요.
71+
72+
type HomeNavigationPages = Exclude<NavigationPages, "home">;
73+
74+
// Extract<Type, MatchUnion>
75+
76+
// MatchUnion하고 겹칠 때 포함되는
77+
// Type 프로퍼티의 모든 프로퍼티 타입을 만드세요.
78+
79+
type DynamicPages = Extract<NavigationPages, "home" | "stickers">;
80+
81+
// NonNullable<Type>
82+
83+
// 프로퍼티 집합에서 null과 undefined를 제외하여 타입을 만드세요.
84+
// 유효성 검사를 할 때 유용합니다.
85+
86+
type StickerLookupResult = Sticker | undefined | null;
87+
type ValidatedResult = NonNullable<StickerLookupResult>;
88+
89+
// ReturnType<Type>
90+
91+
// Type에서 반환 값을 추출하세요.
92+
93+
declare function getStickerByID(id: number): Promise<StickerLookupResult>;
94+
type StickerResponse = ReturnType<typeof getStickerByID>;
95+
96+
// InstanceType<Type>
97+
98+
// 클래스의 인스턴스 또는
99+
// 생성자 함수를 가진 객체인 타입을 만드세요.
100+
101+
class StickerCollection {
102+
stickers: Sticker[];
103+
}
104+
105+
type CollectionItem = InstanceType<typeof StickerCollection>;
106+
107+
// Required<Type>
108+
109+
// 모든 선택적 프로퍼티를
110+
// 필수적인 프로퍼티로 변환하는 타입을 만드세요.
111+
112+
type AccessiblePageInfo = Required<PageInfo>;
113+
114+
// ThisType<Type>
115+
116+
// 다른 타입과 다르게, ThisType은 새로운 타입을 반환하지 않는 대신에
117+
// 함수의 내부 this의 정의를 조작합니다.
118+
// TSConfig에서 noImplicitThis를 실행시켰을 때
119+
// ThisType만 사용할 수 있습니다.
120+
121+
// https://www.typescriptlang.org/docs/handbook/utility-types.html

0 commit comments

Comments
 (0)