TypeScript: `type` vs `interface`, lequel choisir ?
poze a month ago334 gadefr
Dans quels cas utiliser type et dans quels cas interface ? Y a-t-il des différences de performance ou de messages d'erreur ?
🤖 Dyagnostik IA
Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.
3 Repons
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.
Konekte pou di lòt moun si li te mache.
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.
Konekte pou di lòt moun si li te mache.
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.
Konekte pou di lòt moun si li te mache.
Sign in and verify your email to post an answer.