nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.69k stars 7.63k forks source link

Param decorator not extracting value when TypeOrmModule is imported to a module #13293

Closed phuffer closed 8 months ago

phuffer commented 8 months ago

Is there an existing issue for this?

Current behavior

When I import TypeOrmModule into a module, @Param decorators in controllers for other modules that do not import the TypeOrmModule stop extracting the param correctly.

Minimum reproduction code

https://github.com/phuffer/controller-broken-example

Steps to reproduce

See example repository README

Expected behavior

Param decorator works.

Package

Other package

@nestjs/typeorm

NestJS version

10.0.0

Packages versions

"dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/typeorm": "^10.0.2",
    "pg": "^8.11.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  }

Node.js version

18.17.0

In which operating systems have you tested?

Other

In my primary project, my controller inside the module that imports the TypeOrmModule still receives parameters correctly, however I was not able to reproduce this in the example project. I also correctly add the connection config in my primary project, but observed the issue still shows when this connection config is not provided - so I omitted the connection config from the example to prevent having to setup a local SQL databse.

kamilmysliwiec commented 8 months ago

https://github.com/nestjs/nest/issues/13146

TLDR; make sure you use the latest version (so reflect-metadata version is in sync)

OSA413 commented 7 months ago

OP's error is reproducible with "typeorm": "^0.3.20" And the error is fixed with "typeorm": "^0.3.21-dev.e7649d2" or newer (I run npm i typeorm@0.3.21-dev.e7649d2 after checking that original code is still erroring).