Skip to content

Commit

Permalink
Merge pull request #154 from clauderic/update-first-argument-implemen…
Browse files Browse the repository at this point in the history
…tation

Update implementation of FirstArgument
  • Loading branch information
clauderic committed Mar 24, 2021
2 parents a480e03 + 6a5c8a1 commit a232db2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/update-firstargument-implementation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@dnd-kit/utilities": patch
"@dnd-kit/modifiers": patch
---

Update implementation of FirstArgument
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 a232db2

Please sign in to comment.