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

553 - Deep object to unique #1163

Open
emandirola opened this issue Mar 28, 2021 · 2 comments
Open

553 - Deep object to unique #1163

emandirola opened this issue Mar 28, 2021 · 2 comments
Labels
553 answer Share answers/solutions to a question en in English

Comments

@emandirola
Copy link

// your answers
type DeepObjectToUniq<O extends object> = {
  [k in keyof O]: O[k] extends object ? DeepObjectToUniq<O[k]> & { _uniq?: [O, k] } : O[k]
}
@emandirola emandirola added answer Share answers/solutions to a question en in English labels Mar 28, 2021
@github-actions github-actions bot added the 553 label Mar 28, 2021
@huanguolin
Copy link

Nice!
But will fail on IsFalse<Equal<DeepObjectToUniq<Quz>, Quz>>

@rattonlzh
Copy link

rattonlzh commented Apr 23, 2023

type DeepObjectToUniq<O extends object> = {
  [k in keyof O]: O[k] extends object ? DeepObjectToUniq<O[k]> & { [unique: symbol]: [O, k] } : O[k]
} & { [unique: symbol]: O }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
553 answer Share answers/solutions to a question en in English
Projects
None yet
Development

No branches or pull requests

3 participants