Parameters
提出詳細
type MyParameters<T extends (...args: any[]) => any> = T extends ((...name: infer Params) => any) ? Params : never
提出日時 | 2023-09-13 02:33:22 |
---|---|
問題 | Parameters |
ユーザー | sankantsu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' const foo = (arg1: string, arg2: number): void => {} const bar = (arg1: boolean, arg2: { a: 'A' }): void => {} const baz = (): void => {} type cases = [ Expect<Equal<MyParameters<typeof foo>, [string, number]>>, Expect<Equal<MyParameters<typeof bar>, [boolean, { a: 'A' }]>>, Expect<Equal<MyParameters<typeof baz>, []>>, ]