There are times when you want to merge two generic types in TypeScript, and type inference just isn’t doing it for you. Object.assign’s typing isn’t as precise as it could be, and spreading generics still doesn’t work. I’ve found a way to implement typing when merging objects using some of the new features in TypeScript 2.8. A Sample Problem Let’s start by defining some types we can use as example
![Type-Safe Object Merging (TypeScript 2.8 Edition)](https://cdn-ak-scissors.b.st-hatena.com/image/square/711cd78e2bcf2ff3dcafcbac3cf4fb1f31dc1bc3/height=288;version=1;width=512/https%3A%2F%2Fspin.atomicobject.com%2Fwp-content%2Fuploads%2FAtomic-Object-Spin.jpg)