-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Now we have Mapped Types and keyof, we could add a subtraction operator that only works on literal types:
type Omit<T, K extends keyof T> = {
[P in keyof T - K]: T[P];
};
type Overwrite<T, K> = K & {
[P in keyof T - keyof K]: T[P];
};
type Item1 = { a: string, b: number, c: boolean };
type Item2 = { a: number };
type T1 = Omit<Item1, "a"> // { b: number, c: boolean };
type T2 = Overwrite<Item1, Item2> // { a: number, b: number, c: boolean };
alitaheri, yortus, tinganho, aluanhaddad, wclr and 158 moreshyndman, hanakla, krzkaczor, cike8899, rcreasi and 1 moreabenhamdine, jkoritzinsky, kaoDev, merrywhether, maximyanovsky and 23 more
Metadata
Metadata
Assignees
Labels
FixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript