Skip to content

Commit

Permalink
Update implementation of FirstArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
Clauderic Demers committed Mar 24, 2021
1 parent a480e03 commit 536428d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export {
export {add, subtract} from './adjustment';
export {CSS, Transform, Transition} from './css';
export {canUseDOM} from './execution-context';
export type {Arguments, ArgumentAtIndex, FirstArgument, Without} from './types';
export type {Arguments, FirstArgument, Without} from './types';
12 changes: 6 additions & 6 deletions packages/utilities/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export type Arguments<T> = T extends (...args: infer U) => any ? U : never;

export type ArgumentAtIndex<
Func,
Index extends keyof Arguments<Func>
> = Arguments<Func>[Index];

export type FirstArgument<T> = ArgumentAtIndex<T, 0>;
export type FirstArgument<T> = T extends (
firstArg: infer U,
...args: Array<any>
) => any
? U
: never;

export type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

0 comments on commit 536428d

Please sign in to comment.