Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to dynamic omit #19

Open
productdevbook opened this issue Sep 11, 2023 · 0 comments
Open

how to dynamic omit #19

productdevbook opened this issue Sep 11, 2023 · 0 comments

Comments

@productdevbook
Copy link

import { omit } from 'filter-anything'

const obj1 = {
  a: 1,
  b: 2,
  c: 3,
}

const obj2 = {
  a: 2,
  c: 3,
  d: 4,
}
type CommonKeys = Extract<keyof typeof obj1, keyof typeof obj2> // 'a' | 'c'

const commonKeyss = Object.keys(obj1).filter(key => obj2.hasOwnProperty(key)) as CommonKeys[] // ['a', 'c']

const aa = omit(obj1, commonKeyss)
aa. // dont working dont a see only `b` 
CleanShot 2023-09-11 at 05 42 09@2x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant