How to use Omit in Typescript to exclude sensitive data

Still trying to leak sensitive data?! Instead of a 'safelist' for WHAT TO INCLUDE, you need a 'blocklist' for what to exclude! Meet Omit. It's the perfect utility type for when you want to return ALMOST everything from an object, but need to guarantee you hide sensitive fields: Yesterday we discussed Pick and it only felt natural for us to discuss Omit today! Share this with a friend and come back tomorrow for another Typescript tip! https://lnkd.in/gSFrRK3V #code #coding #programming #softwareengineering

  • text

Great usage of Omit! I'd also add this doesn't guarantee omission of data at runtime. You'd need some good ol' runtime validation with a type guard or validation library like zod, io-ts, etc.

Like
Reply

To view or add a comment, sign in

Explore content categories