Skip to content

docs: import types used in decorated signatures with import type - #3679

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
ahmadjoya:docs/type-imports-in-decorated-signatures
Oct 30, 2026
Merged

kamilmysliwiec merged 1 commit into
nestjs:masterfrom
ahmadjoya:docs/type-imports-in-decorated-signatures

Conversation

@ahmadjoya

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Docs
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

Three samples import an Express/Fastify type with a plain import { ... } and then use it in a decorated signature:

  • fundamentals/provider-scopes.md: constructor(@Inject(REQUEST) private request: Request) in an @Injectable() class
  • http/mvc.md (Express): root(@Res() res: Response) on a @Get() handler
  • http/mvc.md (Fastify): root(@Res() res: FastifyReply) on a @Get() handler

The tsconfig that nest new generates sets both isolatedModules and emitDecoratorMetadata. With those options, copying any of these samples into a new project fails to compile:

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.

Checked with TypeScript 5.9.3, @nestjs/common 12.3.2, @types/express and fastify 5.12.7, using the compiler options from the schematics tsconfig.json.

What is the new behavior?

The three imports use import type, which is what controllers.md, faq/raw-body.md and http/file-upload.md already do for the same types. All three samples compile with those options.

The other plain express/fastify type imports in the docs (middlewares.md, exception-filters.md, http/performance.md and the ContextIdStrategy sample in provider-scopes.md) don't use the type in a decorated signature, so they compile as they are and I left them alone.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kamilmysliwiec
kamilmysliwiec merged commit 6c493ed into nestjs:master Oct 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants