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.7k stars 7.63k forks source link

Not working typing while creating entity #11490

Closed Flashantik closed 1 year ago

Flashantik commented 1 year ago

Is there an existing issue for this?

Current behavior

i can create model without required field like, or with wrong type. Typescript not does not warn me of an error

Screenshot 2023-04-15 at 19 30 22

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-wf9c5z?file=src/cats/cats.service.ts

Steps to reproduce

No response

Expected behavior

typescript does warn about argument

Package

Other package

@nestjs/mongoose or typegoose.

NestJS version

9.4.0

Packages versions


"dependencies": {
    "@nestjs/common": "^9.0.0",
    "@nestjs/core": "^9.0.5",
    "@nestjs/mongoose": "^9.2.2",
    "@nestjs/platform-express": "^9.0.0",
    "mongoose": "^7.0.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.5.5"
  },
  "devDependencies": {
    "@nestjs/cli": "^9.0.0",
    "@nestjs/schematics": "^9.0.0",
    "@nestjs/testing": "^9.0.0",
    "@types/express": "^4.17.13",
    "@types/jest": "^28.1.4",
    "@types/node": "^18.0.3",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.30.5",
    "@typescript-eslint/parser": "^5.30.5",
    "eslint": "^8.19.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-prettier": "^4.2.1",
    "jest": "^28.1.2",
    "prettier": "^2.7.1",
    "source-map-support": "^0.5.21",
    "supertest": "^6.2.4",
    "ts-jest": "^28.0.5",
    "ts-loader": "^9.3.1",
    "ts-node": "^10.8.2",
    "tsconfig-paths": "^4.0.0",
    "typescript": "^4.7.4"
  },

Node.js version

No response

In which operating systems have you tested?

Other

No response

jmcdo29 commented 1 year ago

Looks to be more an issue with mongoose's typings than Nest. We don't change or modify how Typescript behaves (other than emitting the decorator metadata) so if Mongoose is allowing this, then that's on their types.

Please use our Discord channel (Support). We are using GitHub to track Bug Reports, Feature Requests, and Regressions.