Skip to content

Commit 039627c

Browse files
authored
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).
1 parent 719e08a commit 039627c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/controllers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Handlers often need access to the client’s **request** details. Nest provides
7878
```typescript
7979
@@filename(cats.controller)
8080
import { Controller, Get, Req } from '@nestjs/common';
81-
import { Request } from 'express';
81+
import type { Request } from 'express';
8282

8383
@Controller('cats')
8484
export class CatsController {

0 commit comments

Comments
 (0)