출처: Type Challenges, https://github.com/type-challenges/type-challenges/blob/main/README.ko.md
3312 - Parameters
내장 제네릭 ``Parameters<T>``를 이를 사용하지 않고 구현하세요.
const foo = (arg1: string, arg2: number): void => {}
type FunctionParamsType = MyParameters<typeof foo> // [arg1: string, arg2: number]
풀이
type MyParameters<T extends (...args: any[]) => any> = T extends (...args: infer Params) => any ? Params : never
'알고리즘 > Type Challenges' 카테고리의 다른 글
2 - Get Return Type (0) | 2023.09.17 |
---|---|
898 - Includes (0) | 2023.09.17 |
3060 - Unshift (0) | 2023.09.17 |
3057 - Push (0) | 2023.09.17 |
533 - Concat (0) | 2023.09.06 |