Skip to content

Commit

Permalink
feat(fsfoundation): Add type alias for getting function argument types
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-sankbeil authored and bweissbart committed Nov 2, 2018
1 parent 24c093e commit be36449
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/fsfoundation/src/Arguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Extracts the types of a given function's arguments
*
* Example:
* type MyFunction = (arg1: string, arg2: number) => void;
* type Args = Arguments<MyFunction>; // Args is [string, number]
*
*/
export type Arguments<F extends Function> = F extends (...args: infer A) => any ? A : never;
1 change: 1 addition & 0 deletions packages/fsfoundation/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './Arguments';
export * from './DeepPartial';
export * from './Dictionary';
export * from './Distance';
Expand Down

0 comments on commit be36449

Please sign in to comment.