Let's say I have this interface...
interface User {
uuid: string,
username: string,
favoriteColor: Color,
creditCardNumber: CardNumber,
}
Obviously, I'm not storing credit card numbers like this, but you get the idea. There's some public data, and then data I don't want to be passed around.
How can I create a type that matches User's keys EXCEPT creditCardNumber?
I currently have something like this, but I'm not entirely sure if it's correct:
type PublicDataOnly = Omit<User, "creditCardNumber">;
If an object that has a creditCardNumber key is passed into a function that accepts PublicDataOnly, it should throw a compile-time error. Is Omit<> the correct way to do this, or is there some other wrapper type I should use?