Add type to express Request import in controllers.md

Hi, 

I'm following the official docs to learn Nest.js, and in the `Controllers` docs the snippet introducing `Request object` didn't compile  in `app.controllers.ts` when doing `npm run start:dev` with the following error:

```
src/app.controller.ts:15:24 - error TS1272: A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled.

15   test(@Req() request: Request): string {
                          ~~~~~~~

  src/app.controller.ts:3:10
    3 import { Request } from 'express';
               ~~~~~~~
    'Request' was imported here.
```

Error was fixed when I added `type` to the import.

Using Node.js v24.8.0 and Nest.js 11.0.10, bootstrapped from the official CLI with `nest new <app>`. (`nest -v` => 11.0.10).
This commit is contained in:
Khalid Jebbari
2025-10-09 14:12:43 +02:00
committed by GitHub
parent 719e08af70
commit 039627c137

View File

@@ -78,7 +78,7 @@ Handlers often need access to the clients **request** details. Nest provides
```typescript
@@filename(cats.controller)
import { Controller, Get, Req } from '@nestjs/common';
import { Request } from 'express';
import type { Request } from 'express';
@Controller('cats')
export class CatsController {