holdanddeepdive / typescript-study

4 stars 0 forks source link

[2주차] Easy 풀이 #4

Open sbyeol3 opened 2 years ago

Choozii commented 2 years ago

4.Pick

type MyPick<T, K extends keyof T> = { //첫번째 인자의 key값들만 접근할 수 있도록 함 [P in K] : T[P] }

Choozii commented 2 years ago

7. ReadOnly

type MyReadonly = { readonly [key in keyof T] : T[key] }

Choozii commented 2 years ago

11. Tuple to Object

type TupleToObject<T extends readonly any[]> = { [K in T[number]] : K }

Choozii commented 2 years ago

14. First of Array

type First<T extends any[]> = T extends []? never : T[0]

Choozii commented 2 years ago

18. Length of Tuple

type Length<T extends readonly unknown[]> = T["length"]

Choozii commented 2 years ago

43. Exclude

Choozii commented 2 years ago

189. Awaited

Choozii commented 2 years ago

268. If

type If<C, T, F> = C extends true?T:F

Choozii commented 2 years ago

533. Concat

type Concat<T extends any [], U extends any []> = [...T, ...U]

Choozii commented 2 years ago

898. Includes

type Includes<T extends readonly any[], U> = T extends [infer F, ...infer R]? Equal<F, U> extends true? true : Includes<R, U> : false;

Choozii commented 2 years ago

3057. Push

type Push<T extends any [], U> = [...T, U]

Choozii commented 2 years ago

3060. Unshift

type Unshift<T extends any [], U> = [U, ...T]

Choozii commented 2 years ago

3312. Parameters

type MyParameters<T extends (...args: any[]) => any> = T extends (...args: infer A) => any? A : never;