mirror of
https://github.com/nestjs/docs.nestjs.com.git
synced 2026-02-25 22:15:07 +00:00
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:
@@ -78,7 +78,7 @@ Handlers often need access to the client’s **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 {
|
||||
|
||||
Reference in New Issue
Block a user