Is there an existing issue for this?
Current behavior
When run nest build
with "@nestjs/axios": "^2.0.0" in package.json, I get this Typescript error:
backend2>nest build
node_modules/@nestjs/axios/dist/http.service.d.ts:14:105 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.
14 protected makeObservable<T>(axios: (...args: any[]) => AxiosPromise<T>, ...args: any[]): Observable<AxiosResponse<T, any>>;
~~~~~~~~~~~~~~~~~~~~~
Found 1 error(s).
If I'll manually change type in node_modules/@nestjs/axios/dist/http.service.d.ts
from
protected makeObservable<T>(axios: (...args: any[]) => AxiosPromise<T>, ...args: any[]): Observable<AxiosResponse<T, any>>;
to
protected makeObservable<T>(axios: (...args: any[]) => AxiosPromise<T>, ...args: any[]): Observable<AxiosResponse<T>>;
nest build will run without errors.
Looks like a bug, because we expect to receive Observable with type.
Minimum reproduction code
https://github.com/vladimirverh/repro-nestjs-2.0.0-TS-issue/blob/main/package.json
Steps to reproduce
- yarn install
yarn install v1.22.10
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
nest build
- See error
node_modules/@nestjs/axios/dist/http.service.d.ts:14:105 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.
14 protected makeObservable<T>(axios: (...args: any[]) => AxiosPromise<T>, ...args: any[]): Observable<AxiosResponse<T, any>>;
~~~~~~~~~~~~~~~~~~~~~
Found 1 error(s).
Expected behavior
nest build should run without Typescript errors.
Package version
9.3.6
NestJS version
9.3.6
Node.js version
16.13.1
In which operating systems have you tested?
Other
package.json (in case GitHub url not working):
{
"name": "backend",
"version": "1.0.0",
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"test": "mocha --timeout 90000 --exit"
},
"dependencies": {
"@nestjs/axios": "^2.0.0",
"@nestjs/common": "^9.3.6",
"@nestjs/config": "^2.3.0",
"@nestjs/core": "^9.3.6",
"@nestjs/platform-express": "^9.3.6",
"@nestjs/schedule": "^2.2.0",
"@nestjs/typeorm": "^9.0.1",
"bcrypt": "^5.0.1",
"cache-manager": "^3.4.4",
"cache-manager-redis-store": "^2.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"cookie-parser": "^1.4.5",
"lodash": "^4.17.21",
"pg": "^8.9.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.8.0",
"typeorm": "^0.3.11",
"winston": "^3.7.2",
"yarn": "^1.22.10"
},
"devDependencies": {
"@nestjs/cli": "^9.2.0",
"@nestjs/schematics": "^9.0.4",
"@nestjs/testing": "^9.3.2",
"@types/bcrypt": "^5.0.0",
"@types/cache-manager": "^3.4.2",
"@types/chai": "^4.2.21",
"@types/chai-as-promised": "^7.1.4",
"@types/cron": "^1.7.3",
"@types/express": "^4.17.17",
"@types/body-parser": "^1.19.2",
"@types/faker": "^5.5.8",
"@types/lodash": "^4.14.171",
"@types/mocha": "^9.0.0",
"@types/multer": "^1.4.7",
"@types/newrelic": "^7.0.3",
"@types/node": "^16.18.12",
"@types/sinon": "^10.0.2",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"faker": "^5.5.3",
"mocha": "^9.0.3",
"nodemon": "^2.0.20",
"prettier": "^2.2.1",
"sinon": "^11.1.2",
"ts-loader": "^8.0.18",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typeorm-fixtures-cli": "^1.9.1",
"typescript": "^4.9.5"
}
}