Avatar ·

How to exclude a property from a type in TypeScript (Exclude property from type)

Hi everyone! I'm new to TypeScript and ran into a problem when working with object types. I have a `User` interface that contains many fields: `id`, `name`, `email`, `password`, `createdAt`, `role`, etc. When I return user data from an API, I don't want to expose `password` and `createdAt` to the client (these are internal fields). The problem is that I don't want to create a separate interface for the public representation of the user, because this leads to code duplication. If I add a new field to `User`, I'll have to remember to add it to the public interface as well. Here's an example: ```typescript interface User { id: number; name: string; email: string; password: string; createdAt: Date; role: 'admin' | 'user'; } // How can I get a type without