NestJS · Senior · Question 47 of 75
How can you share DTOs and validation between a Nest backend and a TypeScript front end?
- ✓Correct answer: Put schemas in a shared package (e.g. Zod schemas or contract libraries like ts-rest), or generate a client from the OpenAPI spec
- 2Copy files manually between repos
- 3Front ends can't use TypeScript types from the backend
Explanation
Generated or shared contracts catch breaking API changes at compile time.