Skip to content

feat[DistributiveOmit]: add distributive omit type - #2142

Merged
dayongkr merged 4 commits into
toss:mainfrom
minsoo-web:feat/distributive-omit
Oct 17, 2026
Merged

dayongkr merged 4 commits into
toss:mainfrom
minsoo-web:feat/distributive-omit

Conversation

@minsoo-web

Copy link
Copy Markdown
Member

Summary

Use it to remove properties from a union without losing the properties specific to each member. The built-in Omit only keeps keys shared by all members, whereas DistributiveOmit applies the omission to each member separately.

Changes

I created documents for each language and wrote type implementations and test code

Constraint: 제안된 키 제약 없는 동작과 유니온 멤버별 속성을 유지한다.
Rejected: 기본 Omit만 사용 | 유니온 멤버별 고유 속성이 사라진다.
Confidence: high
Scope-risk: narrow
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
es-toolkit Ready Ready Preview Oct 16, 2026 1:47pm UTC

Request Review

@dayongkr

Copy link
Copy Markdown
Collaborator

Looks good overall!

One thing. es-toolkit/types tries to follow native TS types as closely as possible for usability, so I'd rather have K take PropertyKey like Omit does instead of leaving it unconstrained. Then the body can just reuse Omit.

export type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;

Only the unknown assertion and the "unconstrained" sentence in the docs would need to follow.

Constraint: TypeScript 기본 Omit과 동일하게 키를 PropertyKey로 제한한다.
Rejected: 제약 없는 K 유지 | 기본 타입과 사용 규칙이 달라진다.
Confidence: high
Scope-risk: narrow
@minsoo-web

Copy link
Copy Markdown
Member Author

@dayongkr dayongkr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!!

@dayongkr
dayongkr merged commit 5fa5316 into toss:main Oct 17, 2026
12 checks passed

This branch was successfully deployed

1 active deployment
Preview — da5f8d1e Deployed Oct 16, 2026 by vercel[bot]
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

Successfully merging this pull request may close these issues.

2 participants