diff --git a/packages/fsfoundation/src/Arguments.ts b/packages/fsfoundation/src/Arguments.ts new file mode 100644 index 0000000000..f577b33dfa --- /dev/null +++ b/packages/fsfoundation/src/Arguments.ts @@ -0,0 +1,9 @@ +/** + * Extracts the types of a given function's arguments + * + * Example: + * type MyFunction = (arg1: string, arg2: number) => void; + * type Args = Arguments; // Args is [string, number] + * + */ +export type Arguments = F extends (...args: infer A) => any ? A : never; diff --git a/packages/fsfoundation/src/index.ts b/packages/fsfoundation/src/index.ts index 0c64b2106e..0c7ce11ef9 100644 --- a/packages/fsfoundation/src/index.ts +++ b/packages/fsfoundation/src/index.ts @@ -1,3 +1,4 @@ +export * from './Arguments'; export * from './DeepPartial'; export * from './Dictionary'; export * from './Distance';