// type Length<T extends readonly any[]> =
// 여기까지만 하다가 length를 아는 법 서치하다가 알게 됨
type Length<T extends readonly any[]> = T['length']
실제 값들을 타입으로서 사용할 수 있는데 그 점을 자꾸 까먹는 것 같음 ㅎ
43 - Exclude 🤔
type MyExclude<T, U> = T extends U ? never : T;
189 - Awaited 🤔
tslib 참고
/**
* Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
*/
type Awaited<T> =
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
Awaited<V> : // recursively unwrap the value
never : // the argument to `then` was not callable
T; // non-object or non-thenable
268 - If
type If<C extends Boolean, T, F> = C extends true ? T : F
C is true 같은 문법이 뭘까 생각했는데 extends 쓰면 되는 거였음
533 - Concat
type Concat<T extends any[], U extends any[]> = [...T, ...U]
any와 unknown... 둘 다 가능한데 둘의 차이를 더 알아보자
898 - Includes
type Includes<T extends readonly any[], U> = U extends T[number] ? true : false
// 일부 케이스에서 error
3057 - Push
type Push<T extends any[], U> = [...T, U]
concat과 비슷
3060 - Unshift
type Unshift<T extends any[], U> = [U, ...T]
3312 - Parameters
type MyParameters<T extends (...args: any[]) => any> = T extends (...args: infer A) => any ? A : never
4 - Pick
7 - Readonly
11 -Tuple to Object
14 - First of Array
18 - Length of Tuple
43 - Exclude 🤔
189 - Awaited 🤔
268 - If
533 - Concat
898 - Includes
3057 - Push
3060 - Unshift
3312 - Parameters