fix(typescript-nestjs): import ModuleMetadata and Type from the @nestjs/common root

RE
6h ago
+4-3

Fixes #25564.

The bug: configuration.ts imports ModuleMetadata and Type from @nestjs/common/interfaces. @nestjs/common 12 has an exports map that turns this into ./interfaces.js, which doesn't exist, so with moduleResolution: nodenext the generated client fails with TS2307: Cannot find module '@nestjs/common/interfaces'.

The fix: for nestVersion 8 and up the two types are now imported from @nestjs/common itself, where they have been exported since 7.x. The nestVersion=6.0.0 output keeps the old import on purpose, the 6.x root doesn't export ModuleMetadata and the v6 sample would stop compiling. That's why the import moved into the existing useAxiosHttpModule blocks instead of being changed in place.

I generated the petstore client before and after and compiled it against @nestjs/common 12.3.3 with TypeScript 6 and nodenext: TS2307 before, clean after. The v6 and v8 samples still pass tsc --noEmit the way bin/ts-typecheck-all.sh runs it. ./bin/generate-samples.sh bin/configs/typescript-nestjs*.yaml changes one line in two samples, the v6 sample is untouched.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

cc @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim


Summary by cubic

Fixes TS2307 errors in generated TypeScript NestJS clients by importing ModuleMetadata and Type from the @nestjs/common root instead of the @nestjs/common/interfaces subpath, which no longer resolves under @nestjs/common 12 with moduleResolution: nodenext.

  • The root package has exported both types since 7.x, so the fix applies to all nestVersion 8+ outputs.
  • The nestVersion=6.0.0 output keeps the old subpath import on purpose because the 6.x root doesn't export ModuleMetadata.
  • Verified by compiling the regenerated petstore client against @nestjs/common 12.3.3 with TypeScript 6 and nodenext; the v6 and v8 samples still pass typechecking.