Skip to content

Commit

Permalink
improve typing of array-omit (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
Masa-Shin authored Sep 10, 2022
1 parent af091d7 commit aa9d21e
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 aa9d21e

Please sign in to comment.