Skip to main content
Telegram logo Mastodon logo

Check of spread in TS

Recently, my colleagues found an interesting case of checking the conforming shape of an object to type in TS if it was extended with another object by spread operator. And yes, TS in that case just ignore validation of unknown fields for type. It's a good reminder that usage of spread operator should be minimized as much as possible. Better to think twice about structures in your project and do not use it for business model entities at all

Link to playground