TypeScript: `type` vs `interface`, lequel choisir ?
asked a month ago335 viewsfr
Dans quels cas utiliser type et dans quels cas interface ? Y a-t-il des différences de performance ou de messages d'erreur ?
🤖 AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
3 Answers
Prisma is the most productive choice: typed client, prisma migrate for versioned SQL, and migrate deploy in CI/production. Keep migrations in git, never edit applied ones, and run migrate deploy as a release step.
Sign in to tell others whether this worked.
Wrap handlers so rejections reach your error middleware:
const wrap = fn => (req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);
app.get('/x', wrap(async (req, res) => { /* ... */ }));
Or upgrade to Express 5, which does this automatically.
Sign in to tell others whether this worked.
Use interface for object shapes you might extend or that represent a public API; use type for unions, intersections, mapped and conditional types. Performance is identical for simple cases; interface error messages are sometimes cleaner.
Sign in to tell others whether this worked.
Sign in and verify your email to post an answer.