Question · JavaScript and TypeScript course · Module 10: TypeScript in Practice

Typing Routes in Express

How do you type request parameters (params, body, query) in Express with TypeScript?

Answer options

  • Using @Param, @Body, @Query decorators on function parameters
  • Through generics Request<Params, ResBody, ReqBody, Query> in Express
  • Typing is not possible - Express always uses any
  • Using an express.config.json file with type definitions

You can check the correct answer by solving this task in the CodeWorlds game.