From 306aff37660b5d48fcb34e34ef12f76711a55c2b Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Mon, 12 Dec 2022 19:32:52 +0800 Subject: [PATCH] sync lodash (#391) * sync lodash * update * update * update * update * update * update * add test case --- src/omit.ts | 2 +- tests/omit.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/omit.ts b/src/omit.ts index b15ccfbc..91451fee 100644 --- a/src/omit.ts +++ b/src/omit.ts @@ -1,6 +1,6 @@ export default function omit( obj: T, - fields: K[], + fields: K[] | readonly K[], ): Omit { const clone = { ...obj }; diff --git a/tests/omit.test.ts b/tests/omit.test.ts index 21a56846..470f3598 100644 --- a/tests/omit.test.ts +++ b/tests/omit.test.ts @@ -10,4 +10,9 @@ describe('omit', () => { const ret = omit({ bamboo: 1 }, null); expect(ret).toEqual({ bamboo: 1 }); }); + + it('readonly array', () => { + const ret = omit({ keep: 1, ignore: 2 }, ['ignore'] as const); + expect(ret).toEqual({ keep: 1 }); + }); });