To replace selected property types while keeping the rest of a type, remove the overlapping keys with Omit and then intersect the remaining shape with the replacement properties:
type Override<Base, Overrides> = Omit<Base, keyof Overrides> & Overrides;
This is a compile-time type transformation, not a runtime merge or fallback. Your JavaScript still needs to construct or update values accordingly.
As an Amazon Associate I earn from qualifying purchases.
Why an intersection alone does not override a property
An intersection such as Base & Overrides combines the requirements from both types. When both contain the same key with incompatible types, the property must satisfy both declarations; TypeScript does not treat the second type as a replacement. The handbook describes this behavior for intersection types.
For example, number & string is not a property that accepts either a number or a string. If the intended result is to change port from a number to a string, remove the old port before combining in the new one.
#1 Best Overall
Replace selected properties with Omit and an intersection
Omit<Base, keyof Overrides> retains base properties except those whose keys appear in Overrides. Intersecting that result with Overrides gives the override shape ownership of duplicate keys. TypeScript documents Omit among its utility types.
type Override<Base, Overrides> = Omit<Base, keyof Overrides> & Overrides;
type ServerConfig = {
host: string;
port: number;
tls: boolean;
};
type Overrides = {
port: string;
tls?: "required" | "optional";
};
type EffectiveConfig = Override<ServerConfig, Overrides>;
// Equivalent property shape:
// {
// host: string;
// port: string;
// tls?: "required" | "optional";
// }
host remains from the base, while port and tls come from the override shape. Because tls is optional in Overrides, it is optional in the resulting type.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Make every override field optional
When the override type describes fields that may be supplied, rather than fields that must be present, use Partial:
type PartialOverride<Base, Overrides> =
Omit<Base, keyof Overrides> & Partial<Overrides>;
This makes every property from Overrides optional. It does not restore the original base property type when an override is absent: those keys were removed from the base side first. If a value should fall back to the old setting, implement that behavior in the code that builds the value, or design a type that deliberately represents the possible states. Partial changes property optionality; it does not perform runtime fallback.
Choose the pattern that matches the intent
| Approach | Duplicate keys | Required or optional | Use it when |
|---|---|---|---|
Omit<Base, keyof Overrides> & Overrides |
Removed from the base side, then supplied by the override side | As declared in Overrides |
You intentionally replace selected property types. |
Omit<Base, keyof Overrides> & Partial<Overrides> |
Removed from the base side, then supplied by the partial override side | All override properties become optional | Override fields may be omitted and no type-level fallback is intended. |
interface New extends Base |
Duplicate declarations must be compatible; incompatible properties produce an error | As declared, subject to compatibility | You are extending a shape compatibly, not replacing a property type. |
Base & Other |
Both sets of requirements remain | As declared by both types | The shapes contribute distinct members or compatible duplicates. |
Use interface extension when a compatible extension is the goal: TypeScript checks duplicate property declarations for compatibility. Use the Omit-and-intersection pattern when changing a property’s type intentionally. See the handbook’s interface documentation.
Version and edge-case checks
Omit is documented as available beginning with TypeScript 3.5; the TypeScript 3.5 release notes cover its introduction. If a project uses an older compiler, verify utility-type availability before adopting this alias. The utility-types reference records Partial as available since TypeScript 2.1.
TypeScript’s intersection checking has changed across releases. The TypeScript 3.9 release notes, for example, discuss stricter checks involving optional properties and intersections, as well as reducing intersections with incompatible discriminant properties. Union inputs, optional keys, readonly modifiers, index signatures, and generic aliases can have additional interactions; check the exact type with the compiler version and configuration used by your project.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




