Skip to content

Commit

Permalink
improve typing of array-omit
Browse files Browse the repository at this point in the history
  • Loading branch information
Masa-Shin committed Sep 9, 2022
1 parent af091d7 commit 2261ca8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 11 additions & 2 deletions packages/object-omit/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
declare function omit<Obj extends object, Key extends string>(obj: Obj, remove: Key[]): Omit<Obj, Key>;
declare function omit<Obj extends object, Key extends string>(obj: Obj, remove1: Key, ...removeN: Key[]): Omit<Obj, Key>;
declare function omit<Obj extends object, Key extends keyof Obj>(
obj: Obj,
remove: Key[]
): Omit<Obj, Key>;

declare function omit<Obj extends object, Key extends keyof Obj>(
obj: Obj,
remove1: Key,
...removeN: Key[]
): Omit<Obj, Key>;

export default omit
5 changes: 1 addition & 4 deletions packages/object-omit/index.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const obj = {
{
const test: { c: number } = omit(obj, ['a', 'b'])
}
{
const test: { a: number } = omit(obj, ['b', 'c', 'd'])
}
{
const test: { a: number, c: number } = omit(obj, ['b', 'b', 'b'])
}
Expand Down Expand Up @@ -47,4 +44,4 @@ omit({}, {}, 'a');
// @ts-expect-error
omit({ a: 1 }, { a: 1 });
// @ts-expect-error
omit([1, 2, 3], 0);
omit({ a: 1}, ['a', 'b'])

0 comments on commit 2261ca8

Please sign in to comment.