Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Interface 'Response<ResBody>' incorrectly extends interface 'Response'

Im using typescript and express in node.js and when I compile it I get When I compile from typescript I get this bug

node_modules/@types/express-serve-static-core/index.d.ts:505:18 - error TS2430: Interface 'Response<ResBody>' incorrectly extends interface 'Response'.
  Types of property 'locals' are incompatible.
    Type 'Record<string, any>' is missing the following properties from type 'i18nAPI': locale, __, __n, __mf, and 5 more.

505 export interface Response<ResBody = any> extends http.ServerResponse, Express.Response {
                     ~~~~~~~~

from my package.json

"dependencies": {
    "@types/i18n": "^0.8.6",
    "@types/jest": "^26.0.7",
    "@types/moment": "^2.13.0",
    "@types/node": "^14.0.26",
    "@types/node-schedule": "^1.3.0",
    "@types/ws": "^7.2.6",
    "@typescript-eslint/eslint-plugin": "^3.7.0",
    "@typescript-eslint/parser": "^3.7.0",
    "@types/express": "^4.17.7",
    "chokidar": "^3.4.1",
    "dblapi.js": "^2.4.0",
    "discord.js": "^12.2.0",
    "eslint": "^7.5.0",
    "eslint-plugin-jest": "^23.18.2",
    "express": "^4.17.1",
    "findit2": "^2.2.3",
    "i18n": "^0.10.0",
    "jest": "^26.1.0",
    "moment": "^2.27.0",
    "node-schedule": "^1.3.2",
    "npm-check-updates": "^7.0.3",
    "tree-kill": "^1.2.2",
    "ts-jest": "^26.1.4",
    "typescript": "^3.9.7"
}

Anyone know what's wrong?

like image 473
omega Avatar asked Aug 09 '20 19:08

omega


3 Answers

Try npm i -D @types/express-serve-static-core, enable skipLibCheck is not a good idea.

like image 72
fannheyward Avatar answered Oct 13 '22 23:10

fannheyward


Add "skipLibCheck": true in tsconfig.json. It worked for me.

like image 21
Julian.ur Avatar answered Oct 13 '22 23:10

Julian.ur


skipLibCheck is rather a workaround and you should not include it without knowing what you are doing.

The issue is fixed in the latest versions so if you have @types/express install update it to latest npm i -D @types/express@latest or install @types/express-serve-static-core explicitly with npm i -D @types/express-serve-static-core

You can check which version the @types/express-serve-static-core has with:

$ npm ls @types/express-serve-static-core

[email protected] /path/redacted
└─┬ @types/[email protected]
  └── @types/[email protected]
        

From: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/46639

like image 2
kuzdogan Avatar answered Oct 13 '22 23:10

kuzdogan